0

我已经安装了 gem bullet 来增强我的小应用程序(与 Rails 4 Edge 一起运行)的性能

但是,“.includes”方法似乎不起作用:

def index
  @articles = Article.includes(:category)
end

这将返回“无法将符号转换为整数”

当我在 Rails 控制台中运行它时也是如此,对于任何关联我都会遇到同样的错误;.includes 已被弃用,还是我做错了?谢谢

这是完整的跟踪:

/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/associations/preloader/association.rb:106:in `[]'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/associations/preloader/association.rb:106:in `build_scope'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/associations/preloader/association.rb:28:in `scope'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/associations/preloader/association.rb:32:in `records_for'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/associations/preloader/association.rb:80:in `block in associated_records_by_owner'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/associations/preloader/association.rb:80:in `each'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/associations/preloader/association.rb:80:in `each_slice'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/associations/preloader/association.rb:80:in `each'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/associations/preloader/association.rb:80:in `map'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/associations/preloader/association.rb:80:in `associated_records_by_owner'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/associations/preloader/singular_association.rb:9:in `preload'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/associations/preloader/association.rb:19:in `run'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/associations/preloader.rb:129:in `block (2 levels) in preload_one'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/associations/preloader.rb:128:in `each'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/associations/preloader.rb:128:in `block in preload_one'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/associations/preloader.rb:127:in `each'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/associations/preloader.rb:127:in `preload_one'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/associations/preloader.rb:104:in `preload'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/associations/preloader.rb:93:in `block in run'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/associations/preloader.rb:93:in `each'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/associations/preloader.rb:93:in `run'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/relation.rb:570:in `block in exec_queries'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/relation.rb:569:in `each'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/relation.rb:569:in `exec_queries'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/relation.rb:456:in `block in load'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/explain.rb:29:in `logging_query_plan'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/relation.rb:456:in `load'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/relation.rb:197:in `to_a'
bullet (4.3.0) lib/bullet/active_record3x.rb:10:in `to_a'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/relation/delegation.rb:13:in `each'
app/views/articles/index.html.slim:44:in `_app_views_articles_index_html_slim___1140651801917805301_70356832595700'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_view/template.rb:144:in `block in render'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activesupport/lib/active_support/notifications.rb:160:in `instrument'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_view/template.rb:142:in `render'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_view/renderer/template_renderer.rb:49:in `block (2 levels) in render_template'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_view/renderer/abstract_renderer.rb:23:in `block in instrument'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activesupport/lib/active_support/notifications.rb:158:in `block in instrument'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activesupport/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activesupport/lib/active_support/notifications.rb:158:in `instrument'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_view/renderer/abstract_renderer.rb:23:in `instrument'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_view/renderer/template_renderer.rb:48:in `block in render_template'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_view/renderer/template_renderer.rb:56:in `render_with_layout'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_view/renderer/template_renderer.rb:47:in `render_template'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_view/renderer/template_renderer.rb:17:in `render'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_view/renderer/renderer.rb:36:in `render_template'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_view/renderer/renderer.rb:17:in `render'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/abstract_controller/rendering.rb:119:in `_render_template'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_controller/metal/streaming.rb:219:in `_render_template'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/abstract_controller/rendering.rb:112:in `render_to_body'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_controller/metal/rendering.rb:33:in `render_to_body'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_controller/metal/renderers.rb:26:in `render_to_body'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/abstract_controller/rendering.rb:97:in `render'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_controller/metal/rendering.rb:16:in `render'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activesupport/lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activesupport/lib/active_support/core_ext/benchmark.rb:5:in `ms'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_controller/metal/instrumentation.rb:41:in `block in render'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_controller/metal/instrumentation.rb:40:in `render'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_controller/metal/implicit_render.rb:10:in `default_render'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_controller/metal/implicit_render.rb:5:in `send_action'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/abstract_controller/base.rb:189:in `process_action'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_controller/metal/rendering.rb:10:in `process_action'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activesupport/lib/active_support/callbacks.rb:413:in `_run__4416358697319013222__process_action__callbacks'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activesupport/lib/active_support/callbacks.rb:78:in `run_callbacks'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/abstract_controller/callbacks.rb:17:in `process_action'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_controller/metal/rescue.rb:29:in `process_action'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activesupport/lib/active_support/notifications.rb:158:in `block in instrument'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activesupport/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activesupport/lib/active_support/notifications.rb:158:in `instrument'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/abstract_controller/base.rb:136:in `process'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/abstract_controller/rendering.rb:44:in `process'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_controller/metal.rb:195:in `dispatch'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_controller/metal.rb:231:in `block in action'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_dispatch/routing/route_set.rb:77:in `call'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_dispatch/routing/route_set.rb:77:in `dispatch'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_dispatch/routing/route_set.rb:45:in `call'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_dispatch/journey/router.rb:69:in `block in call'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_dispatch/journey/router.rb:57:in `each'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_dispatch/journey/router.rb:57:in `call'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_dispatch/routing/route_set.rb:614:in `call'
bullet (4.3.0) lib/bullet/rack.rb:11:in `call'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.2) lib/rack/etag.rb:23:in `call'
rack (1.4.2) lib/rack/conditionalget.rb:25:in `call'
rack (1.4.2) lib/rack/head.rb:9:in `call'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_dispatch/middleware/params_parser.rb:30:in `call'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_dispatch/middleware/flash.rb:233:in `call'
rack (1.4.2) lib/rack/session/abstract/id.rb:210:in `context'
rack (1.4.2) lib/rack/session/abstract/id.rb:205:in `call'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_dispatch/middleware/cookies.rb:443:in `call'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/query_cache.rb:36:in `call'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:631:in `call'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activerecord/lib/active_record/migration.rb:348:in `call'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activesupport/lib/active_support/callbacks.rb:373:in `_run__1420375788820113751__call__callbacks'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activesupport/lib/active_support/callbacks.rb:78:in `run_callbacks'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_dispatch/middleware/reloader.rb:64:in `call'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/railties/lib/rails/rack/logger.rb:32:in `call_app'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/railties/lib/rails/rack/logger.rb:16:in `block in call'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activesupport/lib/active_support/tagged_logging.rb:67:in `block in tagged'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activesupport/lib/active_support/tagged_logging.rb:25:in `tagged'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activesupport/lib/active_support/tagged_logging.rb:67:in `tagged'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/railties/lib/rails/rack/logger.rb:16:in `call'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.4.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.2) lib/rack/runtime.rb:17:in `call'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/activesupport/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.2) lib/rack/lock.rb:15:in `call'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/actionpack/lib/action_dispatch/middleware/static.rb:63:in `call'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/railties/lib/rails/engine.rb:508:in `call'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/bundler/gems/rails-e63e280bed3a/railties/lib/rails/application.rb:95:in `call'
rack (1.4.2) lib/rack/lock.rb:15:in `call'
rack (1.4.2) lib/rack/content_length.rb:14:in `call'
rack (1.4.2) lib/rack/handler/webrick.rb:59:in `service'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/home/shideneyu/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'

最后但并非最不重要的一点是,错误在哪里:

th Actions   
  tbody
   - @articles.each do |article| <---- This line is highlited for the error
     tr
       td
         div class="span1"

文章型号:

class Article < ActiveRecord::Base
    attr_readonly :user_id

    belongs_to :category
    belongs_to :user

    with_options(dependent: :destroy) do |opts|
      opts.has_many :events, as: :eventable
      opts.has_many :mentions, as: :mentionable
      opts.has_many :comments, as: :commentable
    end

    has_and_belongs_to_many :tags, :uniq => true

    validates_presence_of :category, :content
    validates_uniqueness_of :name, scope: :category_id

end
4

1 回答 1

0

.includes 方法适用于实例,这意味着您的方法应如下所示:

def index @articles = Article.includes(:category).find(1) end

或例如收集

def index @articles = @blog.articles.includes(:category) end

于 2013-04-04T15:13:05.023 回答