charlie.caroff-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jun-08 00:01 UTC
linking to a form submit
Hi, I have a form that looks like this, and it works fine: <% form_for :search_term, :url => { :action => :search} do |f| %> <%= f.text_field ''search_term'' %> <%= submit_tag ''Search'' %> <% end %> I want to make a link that submits to the same action, but I when I try, I get this error: undefined method `stringify_keys!'' for "test search":String Here is my attempted link_to: <%= link_to(truncate(recent_search.search_term, 40), {:controller => ''admin'', :action => ''search'', :search_term => recent_search.search_term }, :method => :post ) %> By the way, this search string displays just fine -- but when I click the link, I get that error. Charlie --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
While helpers are nice, this is *so* simple to do with JavaScript I can''t think of any reason not to do it. Just make sure your form tag has name and id attributes. <A href="#" onclick="document.myform.submit()">Submit</A> On 6/7/07, charlie.caroff-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <charlie.caroff-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, I have a form that looks like this, and it works fine: > > <% form_for :search_term, :url => { :action => :search} do |f| > %> > <%= f.text_field ''search_term'' %> > <%= submit_tag ''Search'' %> > <% end %> > > I want to make a link that submits to the same action, but I when I > try, I get this error: > > undefined method `stringify_keys!'' for "test search":String > > Here is my attempted link_to: > > <%= link_to(truncate(recent_search.search_term, 40), {:controller => > ''admin'', :action => ''search'', :search_term => > recent_search.search_term }, :method => :post ) %> > > By the way, this search string displays just fine -- but when I click > the link, I get that error. > > Charlie > > > > >-- F. Morgan Whitney http://www.blizzo.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 -~----------~----~----~----~------~----~------~--~---