diff options
author | Louise Crow <louise.crow@gmail.com> | 2013-10-24 17:03:52 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2013-12-04 09:32:43 +0000 |
commit | ce262657761c1c47c47e2f6cc7bf683543ebbdb7 (patch) | |
tree | 800fc74aebcbc5dae39800abdf0830f2afa6251e /app/models/info_request_batch.rb | |
parent | 4b2e3ef0b6f5b881597242a4afe1404415256f3b (diff) |
Add check for double submission.
Diffstat (limited to 'app/models/info_request_batch.rb')
-rw-r--r-- | app/models/info_request_batch.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/models/info_request_batch.rb b/app/models/info_request_batch.rb index af6956095..05175a889 100644 --- a/app/models/info_request_batch.rb +++ b/app/models/info_request_batch.rb @@ -16,5 +16,17 @@ class InfoRequestBatch < ActiveRecord::Base validates_presence_of :user validates_presence_of :title + validates_presence_of :body + + # When constructing a new batch, use this to check user hasn't double submitted. + def InfoRequestBatch.find_existing(user, title, body, public_body_ids) + find(:first, :conditions => ['info_request_batches.user_id = ? + AND info_request_batches.title = ? + AND body = ? + AND info_requests.public_body_id in (?)', + user, title, body, public_body_ids], + :include => :info_requests) + end + end |