On 9/12/07, Shandy Nantz
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
> Hi all,
>
> I do a save on some user information in controller called my_controller.
> In my model for User I have a validation for the password:
>
> validates_format_of :password, :with => /^\w+$/, :message =>
''<b style > "color:red">Password must be
alphanumeric</b>'', :on => :save
>
> What I need to do, in this case, is to validate the save except for when
> the save is called by this method in this controller. For example, I
> would like to say:
>
> validates_format_of :password, :with => /^\w+$/, :message =>
''<b style > "color:red">Password must be
alphanumeric</b>'', :on => :save, except =>
> [:submit]
>
> However, the problem here is that :submit is the name for a method in
> the controller and not the model where this validation is taking place.
> And because I never pass the password along as a parameter, the
> validation always fails. Is there a way to do this? Thanks,
Don''t try to make the model behavior on a controller action name.
This problem has been solved by others. Study a plugin like
acts_as_authenticated to see how they do it.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---