Hello, Does anyone know how to use error_messages_for with remote_form_for? Here is my code: <%= error_messages_for ''quotation'' %> <div id="quotation_form"> <% remote_form_for(Quotation.new, :url => { :action => "send_quotation" }) do |f| %> .... .... .... <% end %> The <%= error_messages_for ''quotation'' %> is always replaced by empty space in html as ''quotation'' at that time is nil. Any idea how to make it work without setting ''quotation'' variable in the controller? thanks, bogumbiker
> > The <%= error_messages_for ''quotation'' %> is always replaced by empty > space in html as ''quotation'' at that time is nil. > > Any idea how to make it work without setting ''quotation'' variable in > the controller? > > thanks, > bogumbikertry placing <%= error_messages_for ''quotation'' %> just after the remote_form_for tag -- Posted via http://www.ruby-forum.com/.
On Aug 29, 7:00 pm, Rails List <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > The <%= error_messages_for ''quotation'' %> is always replaced by empty > > space in html as ''quotation'' at that time is nil. > > > Any idea how to make it work without setting ''quotation'' variable in > > the controller? > > > thanks, > > bogumbiker > > try placing > <%= error_messages_for ''quotation'' %> just after the remote_form_for > tag > -- > Posted viahttp://www.ruby-forum.com/.No success. Any other ideas? thanks
2009/8/29 bgumbiker <bogumil.bialous-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> > Hello, > Does anyone know how to use error_messages_for with remote_form_for? > > Here is my code: > > <%= error_messages_for ''quotation'' %> > > <div id="quotation_form"> > <% remote_form_for(Quotation.new, :url => { :action => > "send_quotation" }) do |f| %> > .... > .... > .... > <% end %> > > > The <%= error_messages_for ''quotation'' %> is always replaced by empty > space in html as ''quotation'' at that time is nil. > > Any idea how to make it work without setting ''quotation'' variable in > the controller?I am a bit of a loss to understand what you are doing here, though this may be my problem rather than yours. As I understand it error_messages_for is displays the errors associated with the given variable. If quotation is nil how can it have errors associated with it? You have not described what you are doing to generate some errors that you would like to display. Presumably this is as a result of submitting the form that is being generated, if so what are you doing to get the invalid object back to the displayed page so its errors can be displayed? Colin
Rails List wrote:> >> >> The <%= error_messages_for ''quotation'' %> is always replaced by empty >> space in html as ''quotation'' at that time is nil. >> >> Any idea how to make it work without setting ''quotation'' variable in >> the controller? >> >> thanks, >> bogumbiker >Try this <%= error_messages_for "quotation", :object_name => "quotation" %> After the remote_form_for tag -- Posted via http://www.ruby-forum.com/.
On Aug 30, 4:29 am, bgumbiker <bogumil.bial...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> No success. Any other ideas? > thanksYou need to write some javascript/rjs to (after form submission) render a partial (which displays errors in whatever way you want) and insert that into the appropriate part of the DOM Fred
Thanks for all suggestion. It seems that the only solution is the javascript. bogumbiker On Aug 31, 8:21 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Aug 30, 4:29 am, bgumbiker <bogumil.bial...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > No success. Any other ideas? > > thanks > > You need to write some javascript/rjs to (after form submission) > render a partial (which displays errors in whatever way you want) and > insert that into the appropriate part of the DOM > > Fred
If you''re returning RJS or the like from the AJAX call, the method I''d use would be to wrap the error_messages_for in a div and send back a page.replace call that fills it out. I''ve used this in a couple production apps without problems. --Matt Jones On Aug 29, 4:51 am, bgumbiker <bogumil.bial...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, > Does anyone know how to use error_messages_for with remote_form_for? > > Here is my code: > > <%= error_messages_for ''quotation'' %> > > <div id="quotation_form"> > <% remote_form_for(Quotation.new, :url => { :action => > "send_quotation" }) do |f| %> > .... > .... > .... > <% end %> > > The <%= error_messages_for ''quotation'' %> is always replaced by empty > space in html as ''quotation'' at that time is nil. > > Any idea how to make it work without setting ''quotation'' variable in > the controller? > > thanks, > bogumbiker