# ActionController::RoutingError after using scaffold

**URL:** <https://www.ruby-forum.com/t/actioncontroller-routingerror-after-using-scaffold/187371>\
**Category:** Rails\
**Created:** [April 22, 2010, 8:38am UTC](https://www.ruby-forum.com/t/actioncontroller-routingerror-after-using-scaffold/187371 "2010-04-22T08:38:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wlefevre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/71e660/32.png) [@wlefevre](https://www.ruby-forum.com/u/wlefevre)\
**Post date:** [April 22, 2010, 8:38am UTC](https://www.ruby-forum.com/t/actioncontroller-routingerror-after-using-scaffold/187371/1 "2010-04-22T08:38:38Z")

</div>

Hey there,

I’m new to Ruby and was following a tutorial found here:

> <https://stackoverflow.com/questions/545951/ruby-on-rails-link-to-syntax>

Anyway, I already had my own MySQL database from PHP development so I  
decided to try to create a scaffold off of a table ‘users’.

I get the following error:  
ActionController::RoutingError in Users#index

Showing app/views/users/index.html.erb where line #9 raised:

user\_url failed to generate from {:controller=\>“users”, :action=\>“show”,  
:id=\>#\<…\>}

The issue is coming from this line:  
\<%= link\_to ‘Show’, user %\>

I tried deleting that code and trying this instead:  
\<%= user[“user\_id”] %\> – where user\_id is a field in the users table  
and it printed the user\_id

Is this a known scaffold bug in Ruby installs on Windows? How do I go  
about fixing it?

Thanks,  
Lang

---

<div class="post-metadata">

**Author:** ![wlefevre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/71e660/32.png) [@wlefevre](https://www.ruby-forum.com/u/wlefevre)\
**Post date:** [April 22, 2010, 9:37am UTC](https://www.ruby-forum.com/t/actioncontroller-routingerror-after-using-scaffold/187371/2 "2010-04-22T09:37:26Z")

</div>

My guess is that you havent specified what the primary\_key of the  
users table is. Rails expect it do be “id” if you dont specify it.  
Try adding “set\_primary\_key(:user\_id)” to your user model if you  
havent already.

---

<div class="post-metadata">

**Author:** ![wlefevre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/71e660/32.png) [@wlefevre](https://www.ruby-forum.com/u/wlefevre)\
**Post date:** [April 22, 2010, 10:11am UTC](https://www.ruby-forum.com/t/actioncontroller-routingerror-after-using-scaffold/187371/3 "2010-04-22T10:11:06Z")

</div>

Sharagoz wrote:

> My guess is that you havent specified what the primary\_key of the  
> users table is. Rails expect it do be “id” if you dont specify it.  
> Try adding “set\_primary\_key(:user\_id)” to your user model if you  
> havent already.

That fixed it! Thanks so much!
