Skip to content

Instantly share code, notes, and snippets.

@pigoz
Created August 26, 2011 16:06
Show Gist options
  • Save pigoz/1173761 to your computer and use it in GitHub Desktop.
Save pigoz/1173761 to your computer and use it in GitHub Desktop.
very simple url slug with Rails
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