Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Security code works now, moved to a constant in environment.rb
- Loading branch information
Showing
2 changed files
with
6 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,17 @@ | ||
class User < ActiveRecord::Base | ||
devise :database_authenticatable, :registerable, :trackable, :validatable | ||
|
||
attr_accessible :email, :name, :password, :password_confirmation, :terms_of_service | ||
attr_accessible :email, :name, :password, :password_confirmation, :terms_of_service, :security_code | ||
attr_accessor :security_code | ||
|
||
validates_acceptance_of :terms_of_service, :accept => true | ||
validate :correct_security_code, :on => :create | ||
|
||
protected | ||
|
||
# Security code constant lives in environment.rb | ||
def correct_security_code | ||
errors.add(:security_code, "Security code not valid") if security_code != "1234" | ||
errors.add(:security_code, "Security code not valid") if security_code != SECURITY_CODE | ||
end | ||
|
||
# validates_each :security_code, :on => :create do |record, attr, value| | ||
# record.errors.add attr, "Please enter correct security code" unless value && value == "1234" | ||
# end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters