首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > Ruby Rails >

rails 代码为啥总是提示path不对

2013-01-01 
rails 代码为什么总是提示path不对总是提示如下错误:NoMethodError in Counts#indexShowing counts/index.

rails 代码为什么总是提示path不对
总是提示如下错误:
NoMethodError in Counts#index

Showing counts/index.html.erb where line #19 raised:

undefined method `count_path' for #<ActionView::Base:0x4946e30>
Extracted source (around line #19):

16:     <td><%=h count.dir %></td>
17:     <td><%=h count.memo %></td>
18:     <td><%=h count.operator_id %></td>
19:     <td><%= link_to 'Show', count %></td>
20:     <td><%= link_to 'Edit', edit_count_path(count) %></td>
21:     <td><%= link_to 'Destroy', count, :confirm => 'Are you sure?', :method => :delete %></td>
22:   </tr>
RAILS_ROOT: F:/dev/ruby/ZINSTA~1.0-W/rails_apps/cashio

Application Trace | Framework Trace | Full Trace
F:/dev/ruby/ZINSTA~1.0-W/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/polymorphic_routes.rb:27:in `send!'
F:/dev/ruby/ZINSTA~1.0-W/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/polymorphic_routes.rb:27:in `polymorphic_url'
F:/dev/ruby/ZINSTA~1.0-W/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/polymorphic_routes.rb:31:in `polymorphic_path'
F:/dev/ruby/ZINSTA~1.0-W/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/url_helper.rb:79:in `url_for'
F:/dev/ruby/ZINSTA~1.0-W/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_view/helpers/url_helper.rb:144:in `link_to'
app/views/counts/index.html.erb:19:in `_run_erb_47app47views47counts47index46html46erb'
app/views/counts/index.html.erb:12:in `each'
app/views/counts/index.html.erb:12:in `_run_erb_47app47views47counts47index46html46erb'
Request

但是 controller 里面定义了方法。
[解决办法]
你的counts_controller怎么写的?

楼主是不是打算模拟实现scaffold?
检查下config/routes.rb里有没有
resources :counts

热点排行