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):

4:


5:
6:

7: <% form_tag user_update_url(:id => self.current_user.id), :method
=> ‘post’, :class => ‘editing inline’ do %>
8:

Welcome <%= current_user.name %>


9:

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/ }

Thanks,
Jeremy

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.

:slight_smile:

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!

-Danimal

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