Fixing the routes for tags
After my first forray into tags, I felt like I needed to further refine and enhance my usage of them.
So we had this code chunk:
# in app/controllers/blog_controller.rb def tags # FIXME do routing magic to change :id to :tag @blog_posts = BlogPost.find_tagged_with params[:id] render :action => 'all' end ... # in config/routes.rb map.connect 'blog/tags/:tag', :controller => 'blog', :action => 'tags'
The issue was that I wanted to be using
params[:id]. The cause was that my
map.connect was declared AFTER the default connect string, ie:
# Install the default route as the lowest priority. map.connect ':controller/:action/:id.:format' map.connect ':controller/:action/:id'
Apparently I didn’t read the comments closely enough :) Moving it above the default route, it works like I had hoped.