module ActiveRecord::Integration

def to_param

user_path(user) # => "/users/Phusion"
user = User.find_by(name: 'Phusion')

end
end
name
def to_param # overridden
class User < ActiveRecord::Base

a path using the user's name instead of the user's id:
You can override +to_param+ in your model to make +user_path+ construct

user_path(user) # => "/users/1"
user = User.find_by(name: 'Phusion')

construct a path with the user object's 'id' in it:
resources :users route. Normally, +user_path+ will
For example, suppose that you have a User model, and that you have a

or +nil+ if this record's unsaved.
object. The default implementation returns this record's id as a +String+,
Returns a +String+, which Action Pack uses for constructing a URL to this
def to_param
  return unless id
  Array(id).join(self.class.param_delimiter)
end