Routes and IDs above 9

I feel really silly right now but can’t get past a weird error:

user_update_url failed to generate from
{:controller=>“users”, :id=>10, :action=>“update”}, expected:
{:controller=>“users”, :action=>“update”}, diff: {:id=>10}

Extracted source (around line #7):



7: <% form_tag user_update_url(:id =>, :method
=> ‘post’, :class => ‘editing inline’ do %>

Welcome <%= %>


10: <% if current_user.attribute_present? ‘tagline’ %>

The really weird problem is that I only get this error when the user
has an ID over 9. The ID is set as a bigint in mysql.

What should I be looking for to solve this problem? The route for
that URL looks like this:

map.user_update ‘users/:id/update’, :controller => ‘users’, :action =>
‘update’, :requirements => { :id => /\d/ }


I’ve figured it and and feel pretty stupid. :wink: Did you catch my
problem? It’s the routes requirements was looking for a single digit:

requirements => { :id => /\d/ }

The change was to simply add a “+”:

requirements => { :id => /\d+/ }

Ha ha.


I both love it and hate it when I do things like that.

The 9 was a big giveaway, though. It would have been my first guess: a
constraint on a single digit. Glad you caught it, though. Now you are
your own mentor!


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs