Am learning rails the way most do, by implementing a blog. I've just put tagging in and have got my article view to the point where it's displaying clickable tags when you display an article. The issue is that the links are coming out like this;
http://localhost:3000/articles?tagged_with=development
I would prefer not to have the querystring, and instead have something like;
http://localhost:3000/articles/tagged_with/development
I can't find anything relevant in the "routes inside out" guide on the rails site (lots of useful stuff in there, just not this!)
Complete code here: https://github.com/mikeyhogarth/mikeyblog
Pertinant bits are;
the link in _article.html.erb:
<%= link_to tag, articles_path(:tagged_with => tag) %>
the articles index controller:
def index
if(params[:tagged_with])
@tag = params[:tagged_with]
@articles = Article.tagged_with @tag
else
@articles = Article.all
end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @articles }
end
end
what is the rails best practice way of doing this? Do I need to implement a "tagged_with" action and create a helper or is there some rails routing magic that can sort this out in a jiffy?
EDIT: Eventually found the answer