2009/12/4 hitme <[email protected]>: > when I use > ruby script/generate scaffold publisher name:string > It's worked correctly. > > when I use: > ruby script/generate scaffold Admin::publisher name:string > The command done and no error. > Then I add the following code into routes.rb > > map.namespace :admin do |admin| > admin.resources :publishers > end > > The url http://127.0.0.1:3000/admin/publisher/new was correct. > but when I push the 'create' button.There is a error message: > > ###################################################### > 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> > ###################################################### > > And there is no new item insert into database.
The error means what it says, that @publishers is nil. Presumably something has gone wrong in your create method. Have a look in the log (log/development.log) to see if you get any clues. Otherwise you could debug into create and see what is happening. Have a look at the rails guide on debugging (http://guides.rubyonrails.org/) and also the Getting Started guide if you have not already worked through that. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

