Topic: variable variables in restful path helper methods?
Hello, I have a sort of a problem here,
I have two links here:
<td class="center"><%= link_to 'Edit', edit_income_path(income) %> <%= link_to 'Delete', income_path(income), :method => 'delete', :confirm => 'Really delete?' %></td>
And I use it in seven templates (every template is a little different so I can't make one partial), is there a way I can move those links into an application helper? I tried something like this:
link_to 'Edit', edit_resource_path(resource)
# how do I make the path read the resource variable? :<
# link_to 'Edit', edit_(resource_name?)_path(resource)
link_to 'Del', resource_path(resource), :method => 'delete', :confirm => 'Really delete?'
but the resource would be the instance from the template:
<td class="center"><%= edit_link income %> <%= delete_link income %></td>
I'm not even sure if it can work this way. In PHP you can use $$resource.
Last edited by Ollie (2009-01-30 07:56:37)