Skip to content

Instantly share code, notes, and snippets.

@eqdw
Created November 8, 2010 22:13
Show Gist options
  • Save eqdw/668370 to your computer and use it in GitHub Desktop.
Save eqdw/668370 to your computer and use it in GitHub Desktop.
## routes.rb
match "blog" => "blog#index"
match "blog/:year/:month" => "blog#by_date", :constraints => {:year => /\d{4}/, :month => /\d{2}/}, :as => 'blog'
match "blog/:tag" => "blog#by_tag", :as => 'blog'
##a view:
= link_to "Foo", blog_path(:tag => "bar")
##it tries to route it to the second route, realizes the bound params don't match what the route specifies, and shits
##bricks. I would prefer if it either: a) realized the error of its ways and routed it properly; or b) said 'fuck it' and
##linked to /blog?tag=bar. It doesn't.
##Problem solved with :as => "by_tag". Then in the view I do as_tag_path(:tag => 'bar') instead. The URLs stay the same.
##This is a minor annoyance, but understandable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment