# Help with routes and auto-generated methods

**URL:** <https://www.ruby-forum.com/t/help-with-routes-and-auto-generated-methods/133683>\
**Category:** Rails\
**Created:** [April 2, 2008, 3:52pm UTC](https://www.ruby-forum.com/t/help-with-routes-and-auto-generated-methods/133683 "2008-04-02T15:52:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [April 2, 2008, 3:52pm UTC](https://www.ruby-forum.com/t/help-with-routes-and-auto-generated-methods/133683/1 "2008-04-02T15:52:12Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [April 2, 2008, 4:12pm UTC](https://www.ruby-forum.com/t/help-with-routes-and-auto-generated-methods/133683/2 "2008-04-02T16:12:28Z")

</div>

James B. wrote:

> 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
> 
> …
> 
> But I nonetheless get the error above. My question is why is the method  
> edit\_entity\_client missing? What am I doing wrong?

I am leaving off the trailing \_path/\_url suffix, that is what. The  
correct method call is edit\_entity\_client\_path(entity)
