0

I need just simplify url in my rails app. /nature instead /categories/nature

My routes.rb:

match 'categories/:id' => 'categories#show'

1 Answer 1

1
match ':id' => 'categories#show'

This will make any request to '/something' to categories controller with show action though so you have to take that into account.

If I were you I'd do it more like that:

match ':id' => 'categories#show',:constraints => { :id => /nature|sports|architecture|people|.../ }

This way you can still use '/something' routes as you wish as long they don't match any of the available categories.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! It works! But I forget about link_to in my view(it was like this "/category/#{c.id}")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.