diff options
author | Joachim Filip Ignacy Bartosik <jbartosik@gmail.com> | 2011-07-26 21:11:48 +0200 |
---|---|---|
committer | Joachim Filip Ignacy Bartosik <jbartosik@gmail.com> | 2011-08-01 12:20:06 +0200 |
commit | 74f38784ddaf2a349ad96dc028a1e73250a34b5d (patch) | |
tree | 5ddb94d986bd3a87eb198f941734174d3f5a7056 | |
parent | Add line in site/app/models/proxy.rb for better readability (diff) | |
download | council-webapp-74f38784ddaf2a349ad96dc028a1e73250a34b5d.tar.gz council-webapp-74f38784ddaf2a349ad96dc028a1e73250a34b5d.tar.bz2 council-webapp-74f38784ddaf2a349ad96dc028a1e73250a34b5d.zip |
Add and cleanup validations
-rw-r--r-- | site/app/models/approval.rb | 3 | ||||
-rw-r--r-- | site/app/models/user.rb | 4 | ||||
-rw-r--r-- | site/app/models/vote.rb | 3 | ||||
-rw-r--r-- | site/app/models/voting_option.rb | 2 |
4 files changed, 7 insertions, 5 deletions
diff --git a/site/app/models/approval.rb b/site/app/models/approval.rb index d36232c..923ba97 100644 --- a/site/app/models/approval.rb +++ b/site/app/models/approval.rb @@ -11,8 +11,7 @@ class Approval < ActiveRecord::Base belongs_to :user, :null => false belongs_to :agenda, :null => false - validates_presence_of :user_id - validates_presence_of :agenda_id + validates_presence_of :user_id, :agenda_id validates_uniqueness_of :user_id, :scope => :agenda_id def view_permitted?(field) diff --git a/site/app/models/user.rb b/site/app/models/user.rb index 28195f3..cbcd021 100644 --- a/site/app/models/user.rb +++ b/site/app/models/user.rb @@ -12,6 +12,10 @@ class User < ActiveRecord::Base end has_many :votes + + validates_presence_of :name, :irc_nick, :email + validates_uniqueness_of :name, :irc_nick, :email + # --- Signup lifecycle --- # lifecycle do diff --git a/site/app/models/vote.rb b/site/app/models/vote.rb index 9307cce..a661c5e 100644 --- a/site/app/models/vote.rb +++ b/site/app/models/vote.rb @@ -13,8 +13,7 @@ class Vote < ActiveRecord::Base index [:voting_option_id, :user_id], :unique => true - validates_presence_of :voting_option - validates_presence_of :user + validates_presence_of :voting_option, :user validates_uniqueness_of :voting_option_id, :scope => :user_id validate :user_voted_only_once # --- Permissions --- # diff --git a/site/app/models/voting_option.rb b/site/app/models/voting_option.rb index 9ece560..78e2fd1 100644 --- a/site/app/models/voting_option.rb +++ b/site/app/models/voting_option.rb @@ -10,7 +10,7 @@ class VotingOption < ActiveRecord::Base belongs_to :agenda_item, :null => false has_many :votes - validates_presence_of :agenda_item + validates_presence_of :agenda_item, :description validates_uniqueness_of :description, :scope => :agenda_item_id def name |