Created
August 26, 2011 16:06
-
-
Save pigoz/1173761 to your computer and use it in GitHub Desktop.
very simple url slug with Rails
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
module ApplicationHelper | |
def slugged(field, path_method, record) | |
[self.send(path_method, record), record.send(field).parameterize].join("/") | |
end | |
end | |
# then in your view | |
<%= link_to post.title, slugged(:title, :post_path, post) %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment