Blankman
Blankman

Reputation: 267020

Create POST route doesn't have a prefix

My routes.rb has the following:

namespace :admin do
  root 'dashboard#index'
  resources :users
end

I don't see a prefix for the admin/users#create path for some reason?

rake routes shows:

 POST   /admin/users(.:format)          admin/users#create

I thought it would be:

admin_incidents_create POST   /admin/incidents(.:format)          admin/incidents#create

Because of this, I can't create my form tag correctly:

<%= form_for @user, url: ??? do |f| %>

Why isn't the create_path prefix appearing in my rake routes?

Upvotes: 0

Views: 324

Answers (1)

Long Nguyen
Long Nguyen

Reputation: 373

Try to use namespace in form_for, like this

<%= form_for([:admin, @user]) do |f| %>
 ...
<% end %>

please see this for more detail: here

Upvotes: 2

Related Questions