Hiall, Please bear with me as I am new to rails. I have the following problem: I have 2 models, Client and Product. Product is dependent, and as such, within the Client show view I created a Product creation form, to create products that belong to a client. After successful or unsuccessful creation I return to the Client show view. There I wanted to show any errors if the creation went wrong, but I can''t seem to be able to access the @product I used when trying to create the Product instance, to get to its errors. Do I have to pass that @product when redirecting to client_path(client)? And if so, how? BTW, success works, as I use flash to show that, but with the errors I did want to show them in a different position, above the form. If nothing else works, I guess I should pass the errors to flash, but I don''t know how to do that either. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/FEK3UTBMcVoJ. For more options, visit https://groups.google.com/groups/opt_out.
andreo-FdlSlcb4kYpknbxzx/v8hQ@public.gmane.org
2013-Apr-04 12:59 UTC
Re: Help with error messages
can you show us the piece of code you using to handle the success case? flash is an hash with very useful entries: inside your controller you should be doing something like: flash[:error] = object.errors or something like that if you pass us your controller code it would be easier to help you and what is that you doing on the case of no success. On Wednesday, 3 April 2013 07:35:30 UTC+2, Konstantinos Georgokitsos wrote:> > Hiall, > > Please bear with me as I am new to rails. > > I have the following problem: > > I have 2 models, Client and Product. Product is dependent, and as such, > within the Client show view I created a Product creation form, to create > products that belong to a client. After successful or unsuccessful creation > I return to the Client show view. There I wanted to show any errors if the > creation went wrong, but I can''t seem to be able to access the @product I > used when trying to create the Product instance, to get to its errors. Do I > have to pass that @product when redirecting to client_path(client)? And if > so, how? > > BTW, success works, as I use flash to show that, but with the errors I did > want to show them in a different position, above the form. If nothing else > works, I guess I should pass the errors to flash, but I don''t know how to > do that either. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/dQD41M8-0TQJ. For more options, visit https://groups.google.com/groups/opt_out.