Skip to content

Instantly share code, notes, and snippets.

@shiroginne
Created November 24, 2014 11:33
Show Gist options
  • Save shiroginne/176ef95de8b0222566c7 to your computer and use it in GitHub Desktop.
Save shiroginne/176ef95de8b0222566c7 to your computer and use it in GitHub Desktop.
http://guides.rubyonrails.org/association_basics.html#polymorphic-associations вот твой вариант только вместо pictures будет follower
class Follower
belongs_to :followeable, polymorphic: true
belongs_to :user
class User
has_many :followers, as: :followeable
class Topic
has_many :followers, as: :followeable
class Questions
has_many :followers, as: :followeable
schema.rb
----
followers :id, followeable_id, followeable_type, user_id
users: :id
topics: :id
etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment