# Link\_to question

**URL:** <https://www.ruby-forum.com/t/link-to-question/127301>\
**Category:** Rails\
**Created:** [January 28, 2008, 12:43am UTC](https://www.ruby-forum.com/t/link-to-question/127301 "2008-01-28T00:43:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![longint](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8e7dd6/32.png) [@longint](https://www.ruby-forum.com/u/longint)\
**Post date:** [January 28, 2008, 12:43am UTC](https://www.ruby-forum.com/t/link-to-question/127301/1 "2008-01-28T00:43:10Z")

</div>

I’m a noob trying to learn 2.0 via the AWDR 1.2 book. What I’m doing  
is the depot app and I’m trying to follow the admin/store controller  
way. So right now I have a Product model and I ditched the  
products\_controller and views for an admin\_controller and views.

I’m getting tripped up on the “edit” link on the product index page  
view. So if I were using the standard scaffold created by 2.0 my edit  
link in index would like this:

\<%= link\_to ‘Edit’, edit\_product\_path(product) %\>

And that would link to [http://localhost/5/edit](http://localhost/5/edit) (assuming we’re  
clicking product id of 5)

But that is when there’s a products\_controller. However, I have an  
admin\_controller. What would my link\_to look like for that to work  
correctly? Everything I try gives me a undefined method error telling  
me to stringify\_keys! And after doing some research it’s because I’m  
sending a string value when it expects a hash. And my url string is a  
bit different: [http://localhost/edit/5](http://localhost/edit/5) instead of  
[http://localhost/5/edit](http://localhost/5/edit).  
I’m lost 🙂

Thanks.

---

<div class="post-metadata">

**Author:** ![longint](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8e7dd6/32.png) [@longint](https://www.ruby-forum.com/u/longint)\
**Post date:** [January 28, 2008, 2:38am UTC](https://www.ruby-forum.com/t/link-to-question/127301/2 "2008-01-28T02:38:46Z")

</div>

Ok looks like I goofed up on the edit page… but here is what my  
link\_to looks like now and it works:

\<%= link\_to “Edit”, {:action =\> “edit”, :id =\> product }%\>

I guess my only question is this constructs the url like so:  
[http://localhost/edit/5](http://localhost/edit/5)

But the original (scaffold - product model/products\_controller)  
produces this:  
[http://localhost/5/edit](http://localhost/5/edit)

Both work fine - anything to worry about? I’m guessing this would  
probably be answered with a better understanding of routes.
