From 8802f1a586601dfc4fe78dc82d32b6f1aa881e98 Mon Sep 17 00:00:00 2001 From: Moritz Manner Date: Thu, 9 Nov 2017 17:47:33 +0100 Subject: [PATCH] Added scope to paper. Closes #42 --- app/models/paper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/paper.rb b/app/models/paper.rb index c2240ed..1b5fd91 100644 --- a/app/models/paper.rb +++ b/app/models/paper.rb @@ -3,4 +3,5 @@ class Paper < ActiveRecord::Base validates :venue, presence: true validates :year, presence: true, numericality: { only_integer: true } has_and_belongs_to_many :authors + scope :published_in, ->(year) { where("year == ?", year) } end