Map a Resourceful Route in Rails to Another Controller Class

You can map a resource to a different controller by passing the controller option to the resources method.

resources :posts, controller: "articles"

Without the controller option, the posts resource route will map to the PostsController class.

With the controller option provided, it will map to the ArticlesController class.

$ bin/rails routes -g posts

   Prefix Verb   URI Pattern               Controller#Action
    posts GET    /posts(.:format)          articles#index
          POST   /posts(.:format)          articles#create
 new_post GET    /posts/new(.:format)      articles#new
edit_post GET    /posts/:id/edit(.:format) articles#edit
     post GET    /posts/:id(.:format)      articles#show
          PATCH  /posts/:id(.:format)      articles#update
          PUT    /posts/:id(.:format)      articles#update
          DELETE /posts/:id(.:format)      articles#destroy