Thank you everyone for the previous validation help. I have one last question... Can anyone tell me if there is a standard way to deal with a failed validation and loss of the data that was partially completed on the form. I currently use a redirect back to the same action and lose all the data (obviously). Do I send valid data back and forth in the params hash? if @question.errors.any? redirect_to(:controller => "questions", :action => "new", :minisection_id => session[:minisection_id], :question_type => "standard") There has to be a standard way to do this I assume... -- Posted via http://www.ruby-forum.com/. -- 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 For more options, visit https://groups.google.com/groups/opt_out.
render the view - @question will be given to the view for rendering the previous values render :new if @question.errors.any? On Sat, Mar 2, 2013 at 12:23 PM, Dave Castellano <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> Thank you everyone for the previous validation help. I have one last > question... Can anyone tell me if there is a standard way to deal with a > failed > validation and loss of the data that was partially completed on the > form. I currently use a redirect back to the same action and lose all > the data (obviously). Do I send valid data back and forth in the > params hash? > > if @question.errors.any? > redirect_to(:controller => "questions", :action => "new", > :minisection_id => session[:minisection_id], :question_type => > "standard") > > There has to be a standard way to do this I assume... > > -- > Posted via http://www.ruby-forum.com/. > > -- > 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 > For more options, visit https://groups.google.com/groups/opt_out. > > >-- 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 For more options, visit https://groups.google.com/groups/opt_out.
further this url will help with any other questions http://guides.rubyonrails.org/layouts_and_rendering.html On Sat, Mar 2, 2013 at 12:40 PM, Jodi Showers <jodi-vRiTP4Lz4TuakBO8gow8eQ@public.gmane.org> wrote:> render the view - @question will be given to the view for rendering the > previous values > > render :new if @question.errors.any? > > > On Sat, Mar 2, 2013 at 12:23 PM, Dave Castellano <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote: > >> Thank you everyone for the previous validation help. I have one last >> question... Can anyone tell me if there is a standard way to deal with a >> failed >> validation and loss of the data that was partially completed on the >> form. I currently use a redirect back to the same action and lose all >> the data (obviously). Do I send valid data back and forth in the >> params hash? >> >> if @question.errors.any? >> redirect_to(:controller => "questions", :action => "new", >> :minisection_id => session[:minisection_id], :question_type => >> "standard") >> >> There has to be a standard way to do this I assume... >> >> -- >> Posted via http://www.ruby-forum.com/. >> >> -- >> 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 >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> >-- 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 For more options, visit https://groups.google.com/groups/opt_out.
Jodi S. wrote in post #1099859:> further this url will help with any other questions > > http://guides.rubyonrails.org/layouts_and_rendering.htmlThank you. -- Posted via http://www.ruby-forum.com/. -- 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 For more options, visit https://groups.google.com/groups/opt_out.
When I "render :new", the view gets called correctly but there is a partial in the new.html.erb view which does not render. <%= form_for @question, :as=> :question, :url => { :action => "create"} do |f| %> <% if @question_type == "standard" %> <%= render ''new_and_edit_fields'', f: f %> Can I not render a render?? -- Posted via http://www.ruby-forum.com/. -- 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 For more options, visit https://groups.google.com/groups/opt_out.
Never mind... got it! @question_type == "standard" -- Posted via http://www.ruby-forum.com/. -- 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 For more options, visit https://groups.google.com/groups/opt_out.
Dave, consider this refactor create an instance method in your question model def standard? question_type == "standard" end then your view/controller syntax get a bit more readable @question.standard? On Sat, Mar 2, 2013 at 12:56 PM, Dave Castellano <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> When I "render :new", the view gets called correctly but there is a > partial in the new.html.erb view which does not render. > > <%= form_for @question, :as=> :question, :url => { :action => "create"} > do |f| %> > <% if @question_type == "standard" %> > <%= render ''new_and_edit_fields'', f: f %> > > Can I not render a render?? > > -- > Posted via http://www.ruby-forum.com/. > > -- > 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 > For more options, visit https://groups.google.com/groups/opt_out. > > >-- 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 For more options, visit https://groups.google.com/groups/opt_out.
On 2 March 2013 17:23, Dave Castellano <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Thank you everyone for the previous validation help. I have one last > question... Can anyone tell me if there is a standard way to deal with a > failed > validation and loss of the data that was partially completed on the > form. I currently use a redirect back to the same action and lose all > the data (obviously). Do I send valid data back and forth in the > params hash?My standard response for beginners who have not yet got the basics of rails is to work right through a good tutorial such as railstutorial.org, which is free to use online. That should cover your question and many others that you have yet to ask. Colin -- 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 For more options, visit https://groups.google.com/groups/opt_out.
the view gets called correctly but there is a partial http://www.hqew.net -- Posted via http://www.ruby-forum.com/. -- 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 For more options, visit https://groups.google.com/groups/opt_out.