# ActionController::RoutingError after using scaffold

**URL:** <https://discuss.rubyonrails.org/t/actioncontroller-routingerror-after-using-scaffold/51108>\
**Category:** rubyonrails-talk\
**Created:** [April 22, 2010, 6:38am UTC](https://discuss.rubyonrails.org/t/actioncontroller-routingerror-after-using-scaffold/51108 "2010-04-22T06:38:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [April 22, 2010, 6:38am UTC](https://discuss.rubyonrails.org/t/actioncontroller-routingerror-after-using-scaffold/51108/1 "2010-04-22T06:38:38Z")

</div>

Hey there,

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

[http://stackoverflow.com/questions/545951/ruby-on-rails-link-to-syntax](http://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:** ![Sharagoz](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@Sharagoz](https://discuss.rubyonrails.org/u/Sharagoz)\
**Post date:** [April 22, 2010, 7:27am UTC](https://discuss.rubyonrails.org/t/actioncontroller-routingerror-after-using-scaffold/51108/2 "2010-04-22T07:27:55Z")

</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:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [April 22, 2010, 8:11am UTC](https://discuss.rubyonrails.org/t/actioncontroller-routingerror-after-using-scaffold/51108/3 "2010-04-22T08: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!
