生成scaffold_controller的问题(bug?)

时间:2011-08-19 11:13:07

标签: ruby-on-rails ruby-on-rails-3

我正在尝试使用scaffold_controller生成我的CRUD脚本 我正在使用:

Loading development environment (Rails 3.0.10) 
ruby-1.9.2-p290 :001 > 

我的模型非常简单: class Orgjed<的ActiveRecord :: Base的 结束 在我的架构中,这就是它的写法:

  create_table "orgjeds", :force => true do |t| 
    t.string   "naziv" 
    t.datetime "created_at" 
    t.datetime "updated_at" 
  end 

我正在尝试使用创建控制器和所有脚本 rails生成scaffold_controller Orgjed 之后,脚本似乎一切正常:

... 
      create    app/views/orgjeds/index.html.erb 
      create    app/views/orgjeds/edit.html.erb 
... 

启动服务器并尝试转到正确的路径后,这就是我在浏览器中找到的内容:

NoMethodError in Orgjeds#index 
Showing xxx/ev_rada/app/views/orgjeds/index.html.erb where line #12 
raised: 
undefined method `orgjed_path' for #<#<Class:0x9fbe1dc>:0x9fb0cf8> 
Extracted source (around line #12): 
9: 
10: <% @orgjeds.each do |orgjed| %> 
11:   <tr> 
12:     <td><%= link_to 'Show', orgjed %></td> 
13:     <td><%= link_to 'Edit', edit_orgjed_path(orgjed) %></td> 
14:     <td><%= link_to 'Destroy', orgjed, :confirm => 'Are you 
sure?', :method => :delete %></td> 
15:   </tr> 

另外,我调查了_form.html.erb 并且没有像纳兹夫那样的领域...... 这是一个错误还是我做错了什么? 谢谢

2 个答案:

答案 0 :(得分:1)

好像你错过了配置路线。在routes.rb中添加以下行:

resources :orgjeds

答案 1 :(得分:0)