#rubyonrails - Sat 5 May 2007 between 00:01 and 00:27

NY Lost Funds



nyamthanks court3nay ^^
lambo4josim having problems getting model validation errors to be displayed in the views. i am using restful authentication, and created an edit email and edit password scenarios, and i have implemented model validations for these scenarios, but for some reason they are not being displayed. They do end up in the errors has when i run script/console. can anyone help?
DannoHungJesus H Doublechrist, I have a lot of windows open
lambo4jostypo: they meaning the validation errors end up in the errors hash
court3naylambo4jos: you may need to call 'valid' or 'save' to trigger them
cliffstahhalorgium
http://weblog.jamisbuck.org/2006/10/26/monkey-patching-rails-extending-routes-2
=)
lambo4joscourt3nay: i call save with change_email_address in the model.
DannoHungActionMailer confuses me so.
court3nayand you're doing <%= error_messages_for :user %> ?
or thereabouts
DannoHungSometimes things get sent. Sometimes they don't
lambo4josyes
court3nayand you're not redirecting before showing the page
and not reloading
lambo4jospastie
pastiehttp://pastie.caboo.se/59058 by lambo4jos.
lambo4joscourt3nay: here is my change_email controller action. im a little confused on redirects. i have one redirect at the end of the method.
http://pastie.caboo.se/59058
court3naya redirect will call a new action
therefore your validations will not show
as i said, you need to call 'save' or 'valid?' in order for errors to show.
if you redirect, you haven't called save, have you?
you've called find but tha'ts it
lambo4josi call save in the model before the redirect is called
court3naywhat happens when you redirect?
it's a whole new request
lambo4josoh. i am only calling save when it changes the email in the model. i don;t call save when it doesn't change the email
court3nayalso, if an object is not valid, it will not save
lambo4josis this what i am looking for?
court3nayno
ok
1. if its invalid it will not save
2. if you redirect, it's a new request
those combined
you need some code something like this
blah.email = params[:email]
if !blah.save
return

Page: 2 9 16 23 30 37 44 51 58 65 72 79 86 93 

IrcArchive

NY Lost Funds