Skip to content

Instantly share code, notes, and snippets.

@pjg
Created February 13, 2010 23:38
Show Gist options
  • Save pjg/303742 to your computer and use it in GitHub Desktop.
Save pjg/303742 to your computer and use it in GitHub Desktop.
def default_url_options(options = {})
# resource hack so that url_for(@post) works like it should
# if a post was given as a parameter to `post_path` it will be assigned to the first (unnassigned) parameter of the route (year)
if options[:controller] == "posts" && options[:year].is_a?(Post)
post = options[:year]
options[:year] = post.year
options.merge(:month => post.month, :slug => post.slug)
else
{}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment