On Sep 1, 2011, at 9:13 AM, 7stud -- wrote:
> Philip Hallstrom wrote in post #1019611:
>>
>> could be false for any number of reasons -- perhaps you have a
>> validation that rejects "example.com" as a valid email address.
>>
>
> Does he? Here's his model:
No, he doesn't. Sorry, I should have been more clear. The problem with using valid? is that at some point he *may* add a validation that causes the user to be invalid even though the password is *okay*. Now you've got a test for password failing even though the password is okay and that leads to madness :)
> class User < ActiveRecord::Base
> has_many :accounts, :dependent => :destroy
>
> validates :email, :presence => true
> validates :name, :presence => true
> validates :password, :presence => true, :length =>
> { :minimum => 8, :maximum => 2000, :message => 'should be between 8
> and 2000 characters' }
> validates :security_question, :presence => true
> validates :security_answer, :presence => true
> validates :mobile_phone, :length =>
> { :minimum => 8, :maximum => 30, :message => 'should be between 8 and
> 30 characters'}
>
> end
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment