Skip to content

Instantly share code, notes, and snippets.

@markauskas
Forked from pjg/application_controller.rb
Created February 14, 2010 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markauskas/303758 to your computer and use it in GitHub Desktop.
Save markauskas/303758 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