diff --git a/app/models/ability.rb b/app/models/ability.rb index caf8f2a4..4fc5ae34 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -122,9 +122,7 @@ class Ability # if not, do not allow replies. # do not allow replies before the start_date or after the end_date of survey - cannot :reply, Survey do |survey| - survey.start_date > Time.current || survey.end_date < Time.current - end + cannot :reply, Survey, &:closed? can [:destroy], Openid diff --git a/app/models/survey.rb b/app/models/survey.rb index 50e251a7..66783e90 100644 --- a/app/models/survey.rb +++ b/app/models/survey.rb @@ -32,4 +32,8 @@ class Survey < ActiveRecord::Base now <= end_date end end + + def closed? + !active? + end end