Reputation: 7314
I have a Store controller and an Items controller, I want each item to appear under store/ as store/items/id, my routes file is;
match 'store'=> 'store#index'
namespace :store do
resources :items, only: [:show]
end
when I link to an item on the store page I get the correct url e.g 'store/items/1' but when I follow the link I get the error
ActionController::RoutingError at /store/items/1 uninitialized constant Store
I don't know why I'm getting this error...
Upvotes: 0
Views: 487
Reputation: 13014
namespace
rolls up module, name prefix and path prefix.
But in your case, you don't have a module named Store
. It is a controller instead. That is, it is looking for Store::ItemsController
.
Use this instead:
scope '/store' do
resources :items, only: [:show]
end
This will give you the path such as item_path
and URI like /store/items/1
Upvotes: 1