views:

36

answers:

1

To get all the ActiveRecord goodies your class must inherit from ActiveRecord::Base:

class Post < ActiveRecord::Base

Why not ask the user to include ActiveRecord as a module instead?

The advantage of this approach is that Rails could automatically include ActiveRecord in all classes in the models directory, making it completely transparent to the user. I.e.:

class Post # no `< ActiveRecord::Base`!

Is this a (relatively minor) design flaw in Rails?

+1  A: 

ActiveRecord is not Hibernate. ActiveRecord models are not pure models - they are explicit Active Records and follow the semantics of the Active Record pattern.

This is not a design flaw. This is a completely different design goal.

I would certainly like to see a Ruby Hibernate. But ActiveRecord is not it.

Martin Fowler describes an Active Record as:

An object that wraps a row in a database table or view, encapsulates the database access, and adds domain logic on that data.

Justice
Isn't DataMapper more like Hibernate? (Only new to ruby so this might be a misunderstanding.)
Nathan W