Guest User

Untitled

a guest
Jun 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. ## routes.rb
  2. match "blog" => "blog#index"
  3. match "blog/:year/:month" => "blog#by_date", :constraints => {:year => /\d{4}/, :month => /\d{2}/}, :as => 'blog'
  4. match "blog/:tag" => "blog#by_tag", :as => 'blog'
  5.  
  6. ##a view:
  7. = link_to "Foo", blog_path(:tag => "bar")
  8.  
  9.  
  10. ##it tries to route it to the second route, realizes the bound params don't match what the route specifies, and shits
  11. ##bricks. I would prefer if it either: a) realized the error of its ways and routed it properly; or b) said 'fuck it' and
  12. ##linked to /blog?tag=bar. It doesn't.
  13.  
  14.  
  15. ##Problem solved with :as => "by_tag". Then in the view I do as_tag_path(:tag => 'bar') instead. The URLs stay the same.
  16. ##This is a minor annoyance, but understandable
Add Comment
Please, Sign In to add comment