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 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 -- Posted via http://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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. On Apr 22, 8:38 am, William Lang <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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 > > 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 > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
William Lang
2010-Apr-22 08:11 UTC
Re: ActionController::RoutingError after using scaffold
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! -- Posted via http://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.