Skip to content

Instantly share code, notes, and snippets.

@pier-oliviert
Last active August 29, 2015 14:18
Show Gist options
  • Save pier-oliviert/bc23389aea1e7d748b73 to your computer and use it in GitHub Desktop.
Save pier-oliviert/bc23389aea1e7d748b73 to your computer and use it in GitHub Desktop.
<%= url('/:post.year/:post.month/:post.slug', post: post) %>
def url(path, records)
records = records.with_indifferent_access
regex = /(:([a-z]+)\.([a-z]+))/i
path.gsub regex do |match|
records[$2].send($3)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment