Create a gist now

Instantly share code, notes, and snippets.

@palkan /models.rb Secret
Last active Apr 14, 2017

What would you like to do?
EvilSeed Example
class User
has_one :profile
belongs_to :role
belongs_to :forum
has_many :questions
has_many :answers
has_many :votes
end
class Role
has_many :users
end
class Forum
has_many :questions
has_many :popular_questions, -> { order(rating: :desc).limit(10) }, class_name: "Question"
has_many :tracking_pixels
belongs_to :author, class_name: "User"
end
class Question
belongs_to :author, class_name: "User"
has_many :answers
has_many :votes, as: :votable
has_many :voters, through: :votes, source: :user
has_one :best_answer, -> { where(best: true) }, class_name: "Answer"
end
class Answer
belongs_to :author, class_name: "User"
has_many :votes, as: :votable
has_many :voters, through: :votes, source: :user
end
class Vote
belongs_to :votable, polymorphic: true
belongs_to :user
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment