I have a model, Tasks, that can be tagged with the acts as taggable on gem.
The route: get \'mainpage/:tag\', to: \'mainpage#index\', as: :tag
Right now
From http://guides.rubyonrails.org/routing.html section 3.11:
get 'mainpage/*tags, to: 'mainpage#index', as: :tag
Adding this route allows you to have URLs like /mainpage/bills
and /mainpage/bills/tv/furniture
.
The first URL would come into your mainpage#index
method with params[:tags] == 'bills'
, while the second one would come in with params[:tags] == 'bills/tv/furniture'
. You could then simply split params[:tags]
on /
.
Note, for seo purposes, you probably want to come up with some nomenclature for the URLs, i.e. the tags are always alphabetical in the URL or something like that.