[Answered ]-Is there something like django's contenttypes framework for Rails?

1👍

As a commenter already noted, probably You want a polymorphic associations. Consider this example:

class Vote < ActiveRecord::Base
  belongs_to :voteable, polymorphic: true
end

class User < ActiveRecord::Base
  has_many :votes, as: :voteable
end

class Product < ActiveRecord::Base
  has_many :votes, as: :voteable
end

More info here:
http://guides.rubyonrails.org/association_basics.html#polymorphic-associations

1👍

Polymorphic association solving this problem

👤hawk

Leave a comment