Skip to content

Instantly share code, notes, and snippets.

@palkan

palkan/models.rb Secret

Last active April 14, 2017 07:16
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 palkan/9ed8e32846beec62393454d365d68c30 to your computer and use it in GitHub Desktop.
Save palkan/9ed8e32846beec62393454d365d68c30 to your computer and use it in GitHub Desktop.
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