method

to_param

v2.0.3 - Show latest stable - Class: Object
to_param()
public

No documentation available.

# File actionpack/lib/action_controller/routing.rb, line 7
  def to_param
    to_s
  end

1Note

Better slug generation (essentially a to_param replacement)

james ยท Jul 22, 20084 thanks

==== Monkey Patching String

class String
def slugify
  returning self.downcase.gsub(/'/, '').gsub(/[^a-z0-9]+/, '-') do |slug|
    slug.chop! if slug.last == '-'
  end
end
end

==== In a model, or wherever def to_param # Don't need the id here if we're looking up the model by the stored slug. "#{id} #{title}".slugify end