Try... <%= link_to 'Edit', edit_path(rec) %>
I am not positive about "edit_path", but you can run rake routes to get the specific path. -J On Mar 20, 2:36 pm, Bharat Ruparel <rails-mailing-l...@andreas-s.net> wrote: > I am trying to write a simple and generic one table maintenance shared > partial which can be reused to maintain multiple tables with the > following fields: > > id, name, created_by, updated_by. > > I am stuck in generating rest route correctly. Here is an example for a > "crust_types" table inspired by Ryan Bates Forms screencasts. > > Here is the index action from CrustTypeController: > > def index > @crust_types = CrustType.find(:all) > respond_to do |format| > format.html # index.html.erb > format.xml { render :xml => @crust_types } > end > end > > Here is the content of corresponding index.html.erb template: > > <%= render :partial => 'shared/crud_table', :object => @crust_types, > :locals => {:ll => 'crust_type'} %> > > Finally, here are the relevant code snippets from _crud_table.html.erb > partial in the shared folder: > > <% for a_rec in crud_table %> > <tr class="<%= cycle("odd","even") %>"> > <td class="first"><%= a_rec.id %></td> > <td><%= a_rec.name %></td> > <td><%= a_rec.created_at %></td> > <td><%= a_rec.updated_at %></td> > <td><%= link_to 'Show', "#{ll}_path" %> | <%= link_to 'Edit', > "edit_#{ll}_path(#{ll})" %> | <%= link_to 'Destroy', "#{ll}_path" , > :confirm => 'Are you sure?', :method => :delete %></td> > </tr> > <% end %> > > The rest paths for link_to methods are not being evaluated they are > literally output. For example: I want the link_to 'Edit', > "edit_#{ll}_path(#{ll})" method to generate the correct edit path as > '/crust_types/1/edit for the first record, instead, I get > '/edit_crust_type_path(crust_type)'. Clearly, it is not being > evaluated. How should I do it? > > Thanks in advance for your time. > > Bharat > -- > Posted viahttp://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---