> i have a question about how validates_presence_of works as it pertains
> to a login system. when you create a user for the first time you can
> require that both their password and confirmation password are present.
> but on subsequent updates to the that record you have to enter a
> confirmation password and that''s really annoying.
>
> i''ve been looking around and i''ve seen solutions that
like something
> like tihs:
>
> validates_presence_of :confirmation_password,
:if=>''required''
>
> where does that ":if" part come from? i mean, how did whoever
suggest
> that know that they could do that? is that a Rails or a Ruby thing?
>
> any insight into that mechanism would be much appreciated.
It''s a Rails thing...
http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M000813
Configuration options:
* message - A custom error message (default is: "can.t be blank")
* on - Specifies when this validation is active (default is :save,
other options :create, :update)
* if - Specifies a method, proc or string to call to determine if the
validation should occur (e.g. :if => :allow_validation, or :if =>
Proc.new { |user| user.signup_step > 2 }). The method, proc or string
should return or evaluate to a true or false value.
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---