Last active
December 15, 2015 08:19
-
-
Save rpearce/5230008 to your computer and use it in GitHub Desktop.
Override to_param method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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