#280 ✓resolved
Jakub Suder

to_param should not return an integer

Reported by Jakub Suder | October 6th, 2008 @ 03:10 PM

If there is no :name attribute in a model, then to_param returns id as an integer (Hobo::Model::to_param and alias_method in CompositeModel). It should always return a string, as it is originally done in ActiveRecord::Base:

(id = self.id) ? id.to_s : nil # Be sure to stringify the id for routes

The fact that id is integer causes an exception for me when I'm trying to generate a url using a helper method like destroy_xxx_path ("TypeError: can't convert Fixnum into String" - it's trying to match the id from to_param to a regexp, and it can't do this if id is an integer).

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

People watching this ticket

Pages