nyam | thanks court3nay ^^ |
lambo4jos | im 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? |
DannoHung | Jesus H Doublechrist, I have a lot of windows open |
lambo4jos | typo: they meaning the validation errors end up in the errors hash |
court3nay | lambo4jos: you may need to call 'valid' or 'save' to trigger them |
cliffstah | halorgium http://weblog.jamisbuck.org/2006/10/26/monkey-patching-rails-extending-routes-2 =) |
lambo4jos | court3nay: i call save with change_email_address in the model. |
DannoHung | ActionMailer confuses me so. |
court3nay | and you're doing <%= error_messages_for :user %> ? or thereabouts |
DannoHung | Sometimes things get sent. Sometimes they don't |
lambo4jos | yes |
court3nay | and you're not redirecting before showing the page and not reloading |
lambo4jos | pastie |
pastie | http://pastie.caboo.se/59058 by lambo4jos. |
lambo4jos | court3nay: 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 |
court3nay | a 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 |
lambo4jos | i call save in the model before the redirect is called |
court3nay | what happens when you redirect? it's a whole new request |
lambo4jos | oh. 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 |
court3nay | also, if an object is not valid, it will not save |
lambo4jos | is this what i am looking for? |
court3nay | no 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 |