diff options
author | Uģis Ozols <ugis.ozolss@gmail.com> | 2010-12-03 10:55:09 +0200 |
---|---|---|
committer | Uģis Ozols <ugis.ozolss@gmail.com> | 2010-12-03 10:55:09 +0200 |
commit | 1d7a814fb1a2e7725bc142dfbf9501cfd909c781 (patch) | |
tree | 6c9a28da4605dcf9059b95f142adce73bae26e1b /app | |
parent | 51095b80910618f7ce5bf1d991f46dd5fab5aa2a (diff) | |
download | refinerycms-blog-1d7a814fb1a2e7725bc142dfbf9501cfd909c781.tar.gz refinerycms-blog-1d7a814fb1a2e7725bc142dfbf9501cfd909c781.tar.bz2 refinerycms-blog-1d7a814fb1a2e7725bc142dfbf9501cfd909c781.zip |
Rails 3 validation style.
Diffstat (limited to 'app')
-rw-r--r-- | app/models/blog_category.rb | 3 | ||||
-rw-r--r-- | app/models/blog_comment.rb | 5 | ||||
-rw-r--r-- | app/models/blog_post.rb | 3 |
3 files changed, 4 insertions, 7 deletions
diff --git a/app/models/blog_category.rb b/app/models/blog_category.rb index 89bff27..6d5e886 100644 --- a/app/models/blog_category.rb +++ b/app/models/blog_category.rb @@ -4,8 +4,7 @@ class BlogCategory < ActiveRecord::Base acts_as_indexed :fields => [:title] - validates_presence_of :title - validates_uniqueness_of :title + validates :title, :presence => true, :uniqueness => true has_friendly_id :title, :use_slug => true diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb index f608a1a..8ab1cf3 100644 --- a/app/models/blog_comment.rb +++ b/app/models/blog_comment.rb @@ -10,9 +10,8 @@ class BlogComment < ActiveRecord::Base alias_attribute :message, :body - validates_presence_of :name, :message - validates_format_of :email, - :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i + validates :name, :message, :presence => true + validates :email, :format => { :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i } scope :unmoderated, :conditions => {:state => nil} scope :approved, :conditions => {:state => 'approved'} diff --git a/app/models/blog_post.rb b/app/models/blog_post.rb index 8937e09..f2a1465 100644 --- a/app/models/blog_post.rb +++ b/app/models/blog_post.rb @@ -5,8 +5,7 @@ class BlogPost < ActiveRecord::Base acts_as_indexed :fields => [:title, :body] - validates_presence_of :title - validates_uniqueness_of :title + validates :title, :presence => true, :uniqueness => true has_friendly_id :title, :use_slug => true |