I have a number of validations in client.rb like this... validates_length_of :first_name, :last_name, :maximum => 25, :message => "Maximum 25 characters and numbers combined" and in my clients_controller.rb I have this... def update @client = Client.find(params[:id]) if @client.update_attributes(params[:client]) flash[:notice] = ''Client was successfully updated.'' redirect_to :back else flash[:notice] = ''There was a problem with saving your edits.'' redirect_to :back end end and the first line in my view_code is <%= error_messages_for ''client'' %> my the flash[:notice] (on my layout) displays properly but nothing ever displays in the view code. What detail am I missing? Is it because I am using '':redirect_to :back'' ? -- Craig White <craig-CnJ8jr4MGtxl57MIdRCFDg@public.gmane.org> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On May 24, 12:00 pm, Craig White <c...-CnJ8jr4MGtxl57MIdRCFDg@public.gmane.org> wrote:> What detail am I missing? Is it because I am using > '':redirect_to :back'' ?Yes - you need to use render instead to preserve the errors. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Thu, 2007-05-24 at 11:18 -0700, Phrogz wrote:> On May 24, 12:00 pm, Craig White <c...-CnJ8jr4MGtxl57MIdRCFDg@public.gmane.org> wrote: > > What detail am I missing? Is it because I am using > > '':redirect_to :back'' ? > > Yes - you need to use render instead to preserve the errors.---- OK - that''s why they stopped outputting the ''messages'' I really want to use ''redirect_to'' instead of ''render'' because I have a number of different data entry screens using the same ''update'' method. Is it possible to get the same effect in flash[:notice] - I ask because ''error_messages_for'' is ActionView and doesn''t work in controllers and something like flash[:notice] = error_messages_for ''client'' flash[:notice] = @client.errors flash[:notice] = @client.valid? all don''t work -- Craig White <craig-CnJ8jr4MGtxl57MIdRCFDg@public.gmane.org> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Does anybody has an answer for this? I have the same problem. And adding a new user while the url is : users/save doesn''t seem "REST" to me. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
tfwright-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-May-30 21:12 UTC
Re: problem with error_messages_for
If you need to access formatted errors in controllers your best bet is to use @object.errors.full_messages, which returns an array of error messages corresponding to the LIs that error_message_for prints out. If you are constructing a flash message you might do something like flash[:warning] = @object.errors.full_messages.join(" ") Which will yield something like "Attribute X can''t be blank. Attribute Y must be numeric." etc On May 30, 3:12 pm, LeonB <l...-uqieUXqmKe0iy20DiJE0iw@public.gmane.org> wrote:> Does anybody has an answer for this? I have the same problem. > > And adding a new user while the url is : users/save doesn''t seem > "REST" to me.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Beautiful. Gonna try that. Thanks. But I think Rails won''t remember the post values, right? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---