folks! I wonder how to make url like: site.com/coding/ruby/rails/article-name As you can see there is nested category. I've already looked at acts-as-tree and awesome nested sets, but it makes urls like site.com/rails/article-name.
So, please help me
If you want to use a resource-ful controller, make a route like this:
scope '(*categories)' do
resources :articles
end
this will require using 'article' at the end of your urls: /coding/ruby/rails/articles/article-name
or you can use a route like this:
match '(*categories)/:id' => 'articles#show', :as => :article
this will let you do article_path(:categories => 'coding/ruby/rails', :id => article.friendly_id)
to get /coding/ruby/rails/article-name
If you are using awesome_nested_set, you could generate the categories string by doing something like
article.category.self_and_ancestors.join("/")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With