Skip to content

Instantly share code, notes, and snippets.

@rpearce
Last active December 15, 2015 08:19
Show Gist options
  • Save rpearce/5230008 to your computer and use it in GitHub Desktop.
Save rpearce/5230008 to your computer and use it in GitHub Desktop.
Override to_param method
// Post model
def to_param
sluggify("#{id}-#{location_from}-to-#{location_to}")
end
def sluggify str
slug = str.downcase.gsub(/[^0-9a-z_ -]/i, '')
slug = slug.gsub(/\s+/, '-').squeeze('-')
slug
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment