Skip to content

Commit

Permalink
Use Rails 3 style validations
Browse files Browse the repository at this point in the history
  • Loading branch information
dhedlund authored and aeschright committed Aug 22, 2011
1 parent f51ddb5 commit 5e10b69
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions microrant/app/models/rant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ class Rant < ActiveRecord::Base

belongs_to :user

validates_presence_of :user, :message
validates_length_of :message, :maximum => 10
validates :user, :presence => true
validates :message, :presence => true, :length => { :maximum => 10 }
#validates :message, :length => { :within => 1..10 }

end
2 changes: 1 addition & 1 deletion microrant/app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ class User < ActiveRecord::Base

has_many :rants

validates_presence_of :name
validates :name, :presence => true

end
6 changes: 3 additions & 3 deletions rubything.textile
Original file line number Diff line number Diff line change
Expand Up @@ -695,16 +695,16 @@ bc.. class Rant < ActiveRecord::Base

belongs_to :user

validates_presence_of :user, :message
validates_length_of :message, :maximum => 10
validates :user, :presence => true
validates :message, :presence => true, :length => { :maximum => 10 }

end

class User < ActiveRecord::Base

has_many :rants

validates_presence_of :name
validates :name, :presence => true

end

Expand Down

0 comments on commit 5e10b69

Please sign in to comment.