This week, I file my first major complaint with Rails.
I was innocently running tests and tweakings some views – when I discovered function that should work longer did.
A little background, my app is filled with routes the make the URLs more contextually appropriate and memorable than the standard REST URL construction. If you have any Rails experience – you can see the problem with using the link_to
helper
Rails likes to turn this:
< %= link_to 'Edit', :controller => 'items', :action => 'edit', :id => '1' %>
into this:
/items/1/edit
Now my standard routes are more like this:
/name_of_item_1/edit
If I do something like this, consistent with how my routes are structured:
< %= link_to 'Edit', :controller => 'items', :action => 'edit', :item_name => 'name_of_item_1' %>
link_to
doesn’t pick up the item_name
. If I throw other variables into the mix, say to pre-pop some attributes, link_to
grabs it’s 3 perferred variables and forgets the rest.
Makes me feel like link_to is a lot like scaffolding: great for getting things up and running quickly, but something you want to clear out once you get serious.