The new version of the scaffold how to specify the path

Look at the recent Ruby on rails electronic commerce practice, there is a sentence, scripy/generate scaffold Publisher 'admin/publisher'
Because now I use rails2.0 so it certainly will not succeed.
But I use Ruby script/generate scaffold Publisher 'admin/publisher' name: string
The same will fail.

Ruby script/generate scaffold Publisher name:string can be successfully.
How will publisher to the specified'admin/publihser'.?

By ruby script/generate scaffold admin/Publisher name:string
It can generate. But the access time error

NoMethodError in Admin/publishers#index

Showing app/views/admin/publishers/index.html.erb where line #8 raised:

You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
Extracted source (around line #8):

5:     <th>Name</th>
6:   </tr>
7: 
8: <% @publishers.each do |publisher| %>
9:   <tr>
10:     <td><%=h publisher.name %></td>
11:     <td><%= link_to 'Show', publisher %></td>
RAILS_ROOT: D:/rails/emporium

Started by King at November 21, 2016 - 8:51 AM

The reply to 2009-12-02 09:47:34 was a moderator to delete

Posted by Aubrey at November 28, 2016 - 8:56 AM

This sentence can be
scripy/generate scaffold Admin/Publisher

Posted by Edwiin at November 29, 2016 - 9:06 AM

Scaffold in the project of much use. Suggestions generated controller and action ,router

Posted by Elizabeth at December 02, 2016 - 9:29 AM

Oh, I'm not in the learning stage.!

Scripy/generate scaffold Admin/Publisher generated code still error

[code]
NoMethodError in Admin/publishers#new

Showing app/views/admin/publishers/new.html.erb where line #3 raised:

undefined method `admin_publishers_path' for #<ActionView::Base:0xaf2768c>
Extracted source (around line #3):

1: <h1>New publisher</h1>
2:
3: <% form_for(@publisher) do |f| %>
4: <%= f.error_messages %>
5:
6: <p>
RAILS_ROOT: E:/xx/test

Application Trace | Framework Trace | Full Trace
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/polymorphic_routes.rb:107:in `__send__'
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/polymorphic_routes.rb:107:in `polymorphic_url'
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/polymorphic_routes.rb:114:in `polymorphic_path'
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:298:in `apply_form_for_options!'
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/form_helper.rb:277:in `form_for'
E:/xx/test/app/views/admin/publishers/new.html.erb:3:in `_run_erb_app47views47admin47publishers47new46html46erb'
E:/xx/test/app/controllers/admin/publishers_controller.rb:29:in `new'
[/code]

Posted by King at December 05, 2016 - 10:11 AM

Error message:
NoMethodError in Admin/publishers#new

Showing app/views/admin/publishers/new.html.erb where line #3 raised:

undefined method `admin_publishers_path' for #<ActionView::Base:0xaf2768c>
Extracted source (around line #3):

1: <h1>New publisher</h1>
2:
3: <% form_for(@publisher) do |f| %>
4: <%= f.error_messages %>
5:
6: <p>

Posted by King at December 08, 2016 - 11:08 AM

A few steps:
1.
./script/generate scaffold Admin::Publisher

The 2 edition routes.rb
map.namespace :admin do |admin|
admin.resources :publishers
end

The 3 configuration form the right path
* form_for(@publisher) => form_for([:admin, @publisher])
* <%= link_to 'Show', @publisher %> => <%= link_to 'Show', [:admin, @publisher] %>
* publishers_path => admin_publishers_path
* edit_publisher_path(@publisher) => edit_admin_publisher_path(@publisher)
* new_publisher_path => new_admin_publisher_path

Call it a day, give points.

Posted by Edwiin at December 23, 2016 - 11:25 AM

To configure
map.namespace :admin do |admin|
admin.resources :publishers
end
After. New can be a normal visit. But the change
form_for(@publisher) => form_for([:admin, @publisher])
After the prompt, the access to new:
NoMethodError in Admin/publishers#index

Showing app/views/admin/publishers/index.html.erb where line #8 raised:

You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
Extracted source (around line #8):

5: <th>Name</th>
6: </tr>
7:
8: <% @publishers.each do |publisher| %>
9: <tr>
10: <td><%=h publisher.name %></td>
11: <td><%= link_to 'Show', publisher %></td>

In addition, even if the access to the new.
Click on the create error as follows (and not in the database record generation):


NoMethodError in Admin/publishers#index

Showing app/views/admin/publishers/index.html.erb where line #8 raised:

You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
Extracted source (around line #8):

5: <th>Name</th>
6: </tr>
7:
8: <% @publishers.each do |publisher| %>
9: <tr>
10: <td><%=h publisher.name %></td>
11: <td><%= link_to 'Show', publisher %></td>

Posted by King at December 29, 2016 - 12:15 PM