Reputation: 221
I have a resource that I would like to change the path of.
resources :blog_posts
That makes the path localhost:3000/blog_posts/:id
How do I make it so it instead of having the "blog_posts" in front of it, the id comes right after, like this? localhost:3000/:id
I'm guessing there's a way to make this dynamic, so I don't have to do a get
for every new blog post.
ANSWER
get '/:id', to: 'blog_posts#show', as: :show_blog_post
You need the as: :show_blog_post
because the prefix won't be there. For example, you'll be able to call show_blog_post_path(@blog_post)
Upvotes: 0
Views: 33