routes - Rails "/blog" path uninitialized constant Blog -
i trying setup rails blog @ "website.com/blog" url
i have models , controller setup work going to
website.com/posts
gives me posts , going to
website.com/posts/1/
shows me post, etc, etc. want happen when go
website.com/blog/
i should see posts index (and original url should no longer work). want go to
website.com/blog/posts/1/
to see post , on , forth.
right routes file:
rails.application.routes.draw namespace :blog resources :posts resources :comments end end "/blog", to: "posts#index" end
when go "/blog/" routing error saying "uninitialized constant blog". need create blog model , controller , migrate complete this? i'd rather not since it's running posts requests new url. going wrong way?
i ended finding answer own question here: http://guides.rubyonrails.org/routing.html#controller-namespaces-and-routing
using seems work fine:
scope '/blog' resources :posts resources :comments end end "/blog", to: "posts#index"
the answer ended being found here: http://guides.rubyonrails.org/routing.html#controller-namespaces-and-routing
as usual solution incredibly simple , made me feel idiot not knowing immediately:
scope '/blog' resources :posts resources :comments end end "/blog", to: "posts#index"
Comments
Post a Comment