Created
February 12, 2015 22:03
-
-
Save richardhartme/0c6b022aa072be3e1e91 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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