Skip to content

Instantly share code, notes, and snippets.

@jenrzzz
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jenrzzz/8749099 to your computer and use it in GitHub Desktop.
Save jenrzzz/8749099 to your computer and use it in GitHub Desktop.
class Like < ActiveRecord::Base
belongs_to :likeable, polymorphic: true
belongs_to :user
end
class Project < ActiveRecord::Base
has_many :likes, as: :likeable
end
class Source < ActiveRecord::Base
has_many :likes, as :likeable
end
class User < ActiveRecord::Base
has_many :likes, inverse_of: :user
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment