diff options
| author | mo k <mo@mokhan.ca> | 2012-05-22 07:57:54 -0600 |
|---|---|---|
| committer | mo k <mo@mokhan.ca> | 2012-05-22 07:57:54 -0600 |
| commit | f6b46ba7edffd80cee98abe46ba089ae4e4d733b (patch) | |
| tree | 8cc3afbed9875a55ecf27023e99ce60262888ad9 /app/models | |
| parent | c245b717b187e149b0f93ee924f86b3ef6854342 (diff) | |
trying to figure out why the specs are failing after adding the website validation.
Diffstat (limited to 'app/models')
| -rw-r--r-- | app/models/user.rb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 47652925..416cedf4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,6 +1,17 @@ +class UrlValidation < ActiveModel::Validator + def validate(record) + if(record.website.starts_with? 'http://') + + else + record.errors[:website] << 'is invalid' + end + end +end + class User < ActiveRecord::Base validates :name, :presence => true validates :website, :format => URI::regexp(%w(http https)), :presence => false + #validates_with UrlValidation has_many :authentications devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable attr_accessible :name, :email, :website, :twitter, :facebook, :password, :password_confirmation, :remember_me @@ -26,8 +37,3 @@ class User < ActiveRecord::Base end end -class UrlValidation < ActiveModel::Validator - def validate(record) - - end -end |
