# Linking to a form submit

**URL:** <https://www.ruby-forum.com/t/linking-to-a-form-submit/106280>\
**Category:** Rails\
**Created:** [June 8, 2007, 2:02am UTC](https://www.ruby-forum.com/t/linking-to-a-form-submit/106280 "2007-06-08T02:02:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 8, 2007, 2:02am UTC](https://www.ruby-forum.com/t/linking-to-a-form-submit/106280/1 "2007-06-08T02:02:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 8, 2007, 3:10am UTC](https://www.ruby-forum.com/t/linking-to-a-form-submit/106280/2 "2007-06-08T03:10:04Z")

</div>

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.

Submit

On 6/7/07, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> try, I get this error:  
> the link, I get that error.
> 
> Charlie
> 
> >

–  
F. Morgan Whitney

> **[Home - Blizzo](http://www.blizzo.com)**
>
> Insight. Culture. Passion. OUR STORY About Our Clients We recognize that our clients are the key element in our success and that we play an important part in helping build their business and brand. Whether our client is a small service business or a...
