Hey there,
I'm having some troubles with my routes and hope, somebody can help me.
In my shop I need some additional configuration pages in the backend.
For example, I would like to be able to manage something called "Ingredient".
I've created:
- Ingredients in the database, the table is called "ingredients"
- A model called Ingredient, located in app/model/spree/ingredient.rb.
- Views for showing, editing and deleting ingredients.
- A deface to add the link to the configurations_menu in the admin view.
- The routes for the resource admin
No, when I try to load any admin page, I get this error:
undefined method `admin_ingredients_path' for #<ActionDispatch::Routing::RoutesProxy:0x007f85e8dc35a0>
My routes.rb:
Rails::application.routes.draw do
mount Spree::Core::Engine, :at => '/'
namespace :admin do
resources :ingredients
end
end
The routes that are created:
simon@Ubuntu-1404-trusty-64-minimal:~/spiceshop$ rake routes | grep ingred
admin_ingredients GET /admin/ingredients(.:format) admin/ingredients#index
POST /admin/ingredients(.:format) admin/ingredients#create
new_admin_ingredient GET /admin/ingredients/new(.:format) admin/ingredients#new
edit_admin_ingredient GET /admin/ingredients/:id/edit(.:format) admin/ingredients#edit
admin_ingredient GET /admin/ingredients/:id(.:format) admin/ingredients#show
PATCH /admin/ingredients/:id(.:format) admin/ingredients#update
PUT /admin/ingredients/:id(.:format) admin/ingredients#update
DELETE /admin/ingredients/:id(.:format) admin/ingredients#destroy
The deface:
Deface::Override.new(virtual_path: "spree/admin/shared/sub_menu/_configuration",
name: "ingredients_admin_configurations_menu",
insert_bottom: "[data-hook='admin_configurations_sidebar_menu'], #admin_configurations_sidebar_menu[data-hook]",
text: "<%= configurations_sidebar_menu_item Spree.t(:ingredients), spree.admin_ingredients_path %>",
disabled: false)
When I played with my routes.rb I got it working for a minute, but when I had to restart the web server, I had no more routes at all...
But I think that shows, that database, model, controller and views are working.
I think it has to do something with the routes.rb, whether it says Rails::application.routes.draw or Spree::something
Any help appreciated, thank you!