# Problems changing button\_to to link\_to

**URL:** <https://www.ruby-forum.com/t/problems-changing-button-to-to-link-to/138545>\
**Category:** Rails\
**Created:** [May 24, 2008, 12:26pm UTC](https://www.ruby-forum.com/t/problems-changing-button-to-to-link-to/138545 "2008-05-24T12:26:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pepa007](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/779978/32.png) [@pepa007](https://www.ruby-forum.com/u/pepa007)\
**Post date:** [May 24, 2008, 12:26pm UTC](https://www.ruby-forum.com/t/problems-changing-button-to-to-link-to/138545/1 "2008-05-24T12:26:15Z")

</div>

Hi,

I tried changing button\_to to link\_to without changing other  
parameters.

The path upon clicking the button is 'localhost/generals/  
empty\_creator. Hovering over button and link shows the same path for  
both. But with ‘link\_to’ I get the error ‘Couldn’t find General with  
ID=empty\_creator’. If I add :id =\> “1” to the link\_to tag, it works,  
despite the id is useless as empty\_creator doesn’t require any  
parameters.

What is the correct way of doing this? I want to avoid using such  
tricks which could make the code confusing in future.

Thank you very much!

---

<div class="post-metadata">

**Author:** ![pepa007](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/779978/32.png) [@pepa007](https://www.ruby-forum.com/u/pepa007)\
**Post date:** [May 26, 2008, 1:24pm UTC](https://www.ruby-forum.com/t/problems-changing-button-to-to-link-to/138545/2 "2008-05-26T13:24:57Z")

</div>

The difference is that link\_to is using HTTP method GET, and button\_to  
is using POST. Your application is probably restful, and treats GET  
and POST differently (GET is getting an existing object, POST is  
creating new one).

So if you have restful application (i.e. it cares about HTTP method),  
you can’t replace link\_to with button\_to or vice versa.

izidor
