asdlfkjlkj
asdlfkjlkj

Reputation: 2348

Rails: same controller for multiple routes

I have a ArticleController with route resources :articles and routes are like this

http://localhost:3000/articles

I need the same controller to handle all the CRUD actions below

http://localhost:3000/personal/articles
http://localhost:3000/stuff/articles

So all 3 above routes should be handled by Article controller for all article CRUD actions. How can I do that?

Upvotes: 1

Views: 2032

Answers (1)

Momus
Momus

Reputation: 394

resources :articles
scope '/personal' do
  resources :articles
end
scope '/stuff' do
  resources :articles
end

http://guides.rubyonrails.org/routing.html

Upvotes: 1

Related Questions