Skip to content

Instantly share code, notes, and snippets.

@Hates
Created February 12, 2015 22:03
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 Hates/0c6b022aa072be3e1e91 to your computer and use it in GitHub Desktop.
Save Hates/0c6b022aa072be3e1e91 to your computer and use it in GitHub Desktop.
class Story < ActiveRecord::Base
has_many :story_keywords, order: "score DESC", dependent: :destroy
has_many :keywords, through: :story_keywords, order: "story_keywords.score DESC"
def keywords
super.merge(StoryKeyword.stanford)
end
end
class StoryKeyword < ActiveRecord::Base
belongs_to :keyword
belongs_to :story
def self.stanford
where(source: "stanford")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment