# Map a Resourceful Route in Rails to Another Controller Class

*Published on July 29, 2024*

Tags: Router

---


> This post is part of my&nbsp;[handbook on the Rails Router](/tag/router).

You can map a resource to a different controller by passing the&nbsp;`controller`&nbsp;option to the&nbsp;`resources`&nbsp;method.

```ruby
resources :posts, controller: "articles"
```

Without the&nbsp;`controller`&nbsp;option, the&nbsp;`posts`&nbsp;resource route will map to the&nbsp;`PostsController`&nbsp;class.

With the controller option provided, it will map to the&nbsp;`ArticlesController`&nbsp;class.

```bash
$ 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
```

