Matias Fierro wrote in post #959653:
> I have to objects with common functionalities and a lot of difference.
> So I want that each have his own table but inherit the common
> functionalities from a parent class. How can I do this in Rails ?

class GenericModel < ActiveRecord::Base
  self.abstract_class = true

  # define all the 'common' methods you want in this class
  # (including the default behaviors for common methods)
  # I use methods in this class for providing all my cache
  # fragment management functionality, rendering model instances
  # to PDFs, etc, etc
end

class Person < GenericModel
  # person-specific methods, and overrides of common methods
  # from GenericModel
end

class Address < GenericModel
  # address-specific methods, and overrides of common methods
  # from GenericModel
end

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to