link_to question

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 (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 instead of http://localhost/5/edit.
I'm lost :slight_smile:


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:

But the original (scaffold - product model/products_controller)
produces this:

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