class AbstractModel < ActiveRecord::Base
self.abstract_class = true
end
class Foo < AbstractModel
end
class Bar < AbstractModel
end
Foo and Bar both inherit properties and methods of the Abstract Model while being in separate tables of their own.
The whole purpose of an abstract model is to be inherited by other real models, it has no table.
Abstract models are the models which cannot have objects ( cannot be instantiated ) and hence they don’t have associated table as well.
eg. ActiveRecord::Base. Abstract Model is similar to ActiveRecord::Base with some extra behavior.
# http://octathorpeweb.com/blog/2011/08/09/abstract-classes-in-rubyrails-neat-way-of-extending-activerecord/
# http://my.safaribooksonline.com/book/web-development/ruby/9780132480345/advanced-active-record/ch09lev1sec6
# http://m.onkey.org/namespaced-models
Posted by Sandheep to Sandheep's deck (2013-04-26 06:04)