CafeHey
CafeHey

Reputation: 5820

In Rails how do you change a resources routes url but keep the same url helper methods?

I have a simple resources route in my routes file like this:

resources :posts

I would like to change all the urls that use this to articles, for example /posts/1/edit becomes /articles/1/edit

Now this is as simple as changing resources :posts to resources :articles.

However what i'd like to do it keep all the posts urls in my code to that the helper method posts_url outputs the new url /articles

I've tried a few variations like the following:

resources :posts, to: 'articles', as: 'posts'

but that doesn't seem to work. Any help would be much appreciated thanks.

Upvotes: 1

Views: 348

Answers (1)

Eyeslandic
Eyeslandic

Reputation: 14910

This is all stated in the fine guides on routing

resources :posts, path: 'articles'

Upvotes: 2

Related Questions