journalduhacker/app/models/hidden_story.rb
joshua stein f9b309d342 separate story hiding from voting
A story downvote is considered a flag, just meaning the story has
problems and not necessarily that the user wants to ignore it.  By
moving hiding out of Vote and into a new HiddenStory model, a user
can now both downvote/flag and hide separately, or just one or the
other.
2015-02-11 11:37:03 -06:00

12 lines
282 B
Ruby

class HiddenStory < ActiveRecord::Base
belongs_to :user
belongs_to :story
validates_presence_of :user_id, :story_id
def self.hide_story_for_user(story_id, user_id)
HiddenStory.where(:user_id => user_id, :story_id =>
story_id).first_or_initialize.save!
end
end