I have a select option tag common to all pages, following is the code which I have put in partial, rendered it in layout. <% form_tag :action => "index" do -%> <%= select_tag( "state" , "<option>State 1</option> <option>State 2</option> <option>State 3</option> <option>State 4</option> <option>Feature Article</option>", :onchange => "this.form.submit()") %> <% end -%> On form submit, following is the o/p - ---- Unknown action No action responded to create ----- I need the select option value in the index method, will then select appropriate state and request the state from database. I am newbie, please help me out! Thanks. -- 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 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 -~----------~----~----~----~------~----~------~--~---
Sachin Kale wrote:> > I have a select option tag common to all pages, > following is the code which I have put in partial, rendered it in > layout. > > <% form_tag :action => "index" do -%> > <%= select_tag( "state" , > "<option>State 1</option> > <option>State 2</option> > <option>State 3</option> > <option>State 4</option> > <option>Feature Article</option>", :onchange => "this.form.submit()") %> > <% end -%> > > > On form submit, following is the o/p - > ---- > Unknown action > > No action responded to create > ----- > > I need the select option value in the index method, will then select > appropriate state and request the state from database. > > I am newbie, please help me out! > > Thanks.Since you are telling that this form is in all your pages, maybe you forgot to add the controller name supposed to handle this request. Otherwise, the request is send to the controller related to your current view while displaying this form. Try to update your partial with "my_controller_name" changed to the good one. <% form_tag :controller => "my_controller_name", :action => "index" do -%> Then, in your controller, your state value will be accessible through def index state_value = params[:state] end Guillaume Petit -- 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 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 -~----------~----~----~----~------~----~------~--~---
Guillaume Petit wrote:> Sachin Kale wrote: >> >> I have a select option tag common to all pages, >> following is the code which I have put in partial, rendered it in >> layout. >> >> <% form_tag :action => "index" do -%> >> <%= select_tag( "state" , >> "<option>State 1</option> >> <option>State 2</option> >> <option>State 3</option> >> <option>State 4</option> >> <option>Feature Article</option>", :onchange => "this.form.submit()") %> >> <% end -%> >> >> >> On form submit, following is the o/p - >> ---- >> Unknown action >> >> No action responded to create >> ----- >> >> I need the select option value in the index method, will then select >> appropriate state and request the state from database. >> >> I am newbie, please help me out! >> >> Thanks. > > Since you are telling that this form is in all your pages, maybe you > forgot to add the controller name supposed to handle this request. > Otherwise, the request is send to the controller related to your current > view while displaying this form. > > Try to update your partial with "my_controller_name" changed to the good > one. > > <% form_tag :controller => "my_controller_name", :action => "index" do > -%> > > Then, in your controller, your state value will be accessible through > > def index > state_value = params[:state] > end > > Guillaume PetitThanks Guillaume for your response. I need to have the form submit to controller which displays the form. This form is common to all controllers so I dont want any controller name, when no name is specified it picks the intended controller (i.e the current page) but does not understands the -> :action = ''index''. I tried what you suggested by manually writing the controller name, but the result was same, it does not get the action ''index''. I even tried :action => controller.action_name , which is the index action, but it did not worked. I have to use the workaround - def updatestate state_value = params[:state] redirect_to :action => "index" end Thanks Again for your help:) -- 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 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 -~----------~----~----~----~------~----~------~--~---
Sachin Kale wrote:> Guillaume Petit wrote: >> Sachin Kale wrote: >>> >>> I have a select option tag common to all pages, >>> following is the code which I have put in partial, rendered it in >>> layout. >>> >>> <% form_tag :action => "index" do -%> >>> <%= select_tag( "state" , >>> "<option>State 1</option> >>> <option>State 2</option> >>> <option>State 3</option> >>> <option>State 4</option> >>> <option>Feature Article</option>", :onchange => "this.form.submit()") %> >>> <% end -%> >>> >>> >>> On form submit, following is the o/p - >>> ---- >>> Unknown action >>> >>> No action responded to create >>> ----- >>> >>> I need the select option value in the index method, will then select >>> appropriate state and request the state from database. >>> >>> I am newbie, please help me out! >>> >>> Thanks. >> >> Since you are telling that this form is in all your pages, maybe you >> forgot to add the controller name supposed to handle this request. >> Otherwise, the request is send to the controller related to your current >> view while displaying this form. >> >> Try to update your partial with "my_controller_name" changed to the good >> one. >> >> <% form_tag :controller => "my_controller_name", :action => "index" do >> -%> >> >> Then, in your controller, your state value will be accessible through >> >> def index >> state_value = params[:state] >> end >> >> Guillaume Petit > > Thanks Guillaume for your response. > > I need to have the form submit to controller which displays the form. > > This form is common to all controllers so I dont want any controller > name, when no name is specified it picks the intended controller (i.e > the current page) but does not understands the -> :action = ''index''. > > I tried what you suggested by manually writing the controller name, but > the result was same, it does not get the action ''index''. > > I even tried :action => controller.action_name , which is the index > action, but it did not worked. > > I have to use the workaround - > > def updatestate > state_value = params[:state] > redirect_to :action => "index" > end > > Thanks Again for your help:)I figured out the solution to my problem of calling form - > action index from a layout in => railcast#37 - simple search I was using ''post'' method, plus another mistake was appropriate controller name.. Following will call the index method of the controller that invokes the layout <% form_tag controller.controller_path, :method => ''get'' do %> <%= select_tag("state", "<option>a</option><option>b</option>" ,:onchange => "this.form.submit()") %> <% end -%> Thanks For help! -- 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 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 -~----------~----~----~----~------~----~------~--~---
KathysKode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Jul-01 13:31 UTC
Re: submit form action-> index, from layout
Sachin, Would you mind embellishing this topic with a little code from your application. I find it could be a wonderful way to work around having to use an observe_field. Thank you, Kathleen On Jun 30, 3:32 pm, Sachin Kale <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Sachin Kale wrote: > > Guillaume Petit wrote: > >> Sachin Kale wrote: > > >>> I have a select option tag common to all pages, > >>> following is the code which I have put in partial, rendered it in > >>> layout. > > >>> <% form_tag :action => "index" do -%> > >>> <%= select_tag( "state" , > >>> "<option>State 1</option> > >>> <option>State 2</option> > >>> <option>State 3</option> > >>> <option>State 4</option> > >>> <option>Feature Article</option>", :onchange => "this.form.submit()") %> > >>> <% end -%> > > >>> On form submit, following is the o/p - > >>> ---- > >>> Unknown action > > >>> No action responded to create > >>> ----- > > >>> I need the select option value in the index method, will then select > >>> appropriate state and request the state from database. > > >>> I am newbie, please help me out! > > >>> Thanks. > > >> Since you are telling that this form is in all your pages, maybe you > >> forgot to add the controller name supposed to handle this request. > >> Otherwise, the request is send to the controller related to your current > >> view while displaying this form. > > >> Try to update your partial with "my_controller_name" changed to the good > >> one. > > >> <% form_tag :controller => "my_controller_name", :action => "index" do > >> -%> > > >> Then, in your controller, your state value will be accessible through > > >> def index > >> state_value = params[:state] > >> end > > >> Guillaume Petit > > > Thanks Guillaume for your response. > > > I need to have the form submit to controller which displays the form. > > > This form is common to all controllers so I dont want any controller > > name, when no name is specified it picks the intended controller (i.e > > the current page) but does not understands the -> :action = ''index''. > > > I tried what you suggested by manually writing the controller name, but > > the result was same, it does not get the action ''index''. > > > I even tried :action => controller.action_name , which is the index > > action, but it did not worked. > > > I have to use the workaround - > > > def updatestate > > state_value = params[:state] > > redirect_to :action => "index" > > end > > > Thanks Again for your help:) > > I figured out the solution to my problem of calling form - > action > index from a layout in => railcast#37 - simple search > > I was using ''post'' method, plus another mistake was appropriate > controller name.. > > Following will call the index method of the controller that invokes the > layout > > <% form_tag controller.controller_path, :method => ''get'' do %> > <%= select_tag("state", "<option>a</option><option>b</option>" > ,:onchange => "this.form.submit()") %> > <% end -%> > > Thanks For help! > -- > Posted viahttp://www.ruby-forum.com/.- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---