Reputation: 2888
I am building my first admin section in Rails and I am struggling with routing problems.
My routes.rb
looks like this:
get "admin/menuh"
get 'admin/welcome'
namespace :admin do
resources :users
resources :menuh
resources :menuv
resources :welcome
end
And my views
structure looks like views/admin/users/files. If I will set to url address of browser the url localhost:3000/admin/users/new, so I will get the error message No route matches {:controller=>"users"} (it's in the file views/admin/users/_form.html.erb - this file is generated by scaffold)... so I would like to ask you - where is the problem? Is here anything important, what I am disregarding?
Upvotes: 0
Views: 237
Reputation: 107708
You've set up your form_for
like this, I reckon:
<%= form_for @user do |f| %>
Because the route is in a namespace, you need to tell the form that also:
<%= form_for [:admin, @user] do |f| %>
That should help you fix that issue.
Upvotes: 3