Hi Shandy,
you do something like this in your controller,
(assume User is the name of model)
class MyController < ApplicationController
def create
# do what ever validation you want for the incoming parameters, and
i''ll assume params[:user] contains all attribute necessary for
creation of user
user = User.new(params[:user])
begin
x.save!
rescue Exception => e
puts x.errors[''password''] # this will print the
error
message you have given, so do what ever you want with this( i am just
printing)
# password is the field name in database table, which can be
any column you want.
puts e.message # even this will contains the error
message.
end
end
end
On Sep 11, 8:08 pm, Shandy Nantz
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> In my view I am trying to change my password. When I hit the change
> password button, a method in my controller gets called which calls a
> method in my model to set the password. On entering that Model, however,
> a validation on the format of the password is checked, if it fails it
> kicks back a message, apperently to the Controller? I need to capture or
> recognize that there is a message so I can display that in the veiw and
> let the user know that there password has failed to validate. Any ideas
> on how to do that? Here is the validation check in my Model:
>
> validates_format_of :password, :with => /^\w+$/, :message =>
''<b style > "color:red">Password must be
alphanumeric</b>'', :on => :create
>
> Thanks,
>
> -Shandy
> --
> Posted viahttp://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-/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
-~----------~----~----~----~------~----~------~--~---