Created
November 8, 2010 22:13
-
-
Save eqdw/668370 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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