I am getting the following error when trying to link to an
auto-generated route:
—>
NoMethodError in Entities#index
Showing entities/index.html.erb where line #36 raised:
undefined method `edit_entity_client’ for #ActionView::Base:0x49ea3c8
Extracted source (around line #36):
33: <%- if entity.client.nil? -%>
34: <%= link_to ‘Add Client Role’, new_entity_client(entity)
-%>
35: <%- else -%>
36: <%= link_to ‘Edit Client Role’,
edit_entity_client(entity) -%>
37: <%- end -%>
38:
39:
RAILS_ROOT: C:/Documents and Settings/byrnejb/My Documents/My
Projects/ca.harte-lyne.system/proforma
Application Trace | Framework Trace | Full Trace
app/views/entities/index.html.erb:36:in
_run_erb_47app47views47entities47index46html46erb' app/views/entities/index.html.erb:11:in
each’
app/views/entities/index.html.erb:11:in
_run_erb_47app47views47entities47index46html46erb' app/controllers/entities_controller.rb:13:in
index’
…
Request
Parameters:
None
<—
The routes.rb file contains this:
…
map.resources :entities do |entity|
# An entity can only have one client role
entity.resource :client
entity.resources :locations
# And only one vendor role
entity.resource :vendor
end
…
and the link_to targets, new_entity_client and edit_entity_client, both
show up when I perform a rake routes:
rake routes
…
new_entity_client GET /entities/:entity_id/client/new
{:controller=>“clients”, :action=>“new”}
formatted_new_entity_client GET
/entities/:entity_id/client/new.:format
{:controller=>“clients”, :action=>“new”}
edit_entity_client GET /entities/:entity_id/client/edit
{:controller=>“clients”, :action=>“edit”}
formatted_edit_entity_client GET
/entities/:entity_id/client/edit.:format
{:controller=>“clients”, :action=>“edit”}
…
But I nonetheless get the error above. My question is why is the method
edit_entity_client missing? What am I doing wrong?