我收到奇怪的随机未定义方法错误(标题上的那个)。我正在使用rubymine IDE,当我收到此错误时,我必须关闭它并重新启动瘦服务器。它没有模式,突然它只是抛出这个错误/
错误是:
undefined method `to_sym' for Array
它发生在我访问某个模型的子代码的代码部分。让我们说父模型是Account,Account has_many Items。当抛出错误时,我尝试访问帐户项目(@ account.items)的rails app的每个部分都会返回该错误。可能是什么原因?我附加了堆栈跟踪和模型架构总结:
class Account < ActiveRecord::Base
has_many :items
has_many :orders, :through => :items
end
开发数据库是MySql。
更新
堆栈跟踪:
NoMethodError - undefined method `to_sym' for #<Array:0x00000006a6daa0>:
activerecord (3.2.13) lib/active_record/attribute_methods/time_zone_conversion.rb:60:in `create_time_zone_conversion_attribute?'
activerecord (3.2.13) lib/active_record/attribute_methods/time_zone_conversion.rb:24:in `attribute_cast_code'
activerecord (3.2.13) lib/active_record/attribute_methods/serialization.rb:80:in `attribute_cast_code'
activerecord (3.2.13) lib/active_record/attribute_methods/read.rb:84:in `define_external_attribute_method'
activerecord (3.2.13) lib/active_record/attribute_methods.rb:67:in `block (2 levels) in define_attribute_methods'
activerecord (3.2.13) lib/active_record/attribute_methods.rb:67:in `block in define_attribute_methods'
<internal:prelude>:10:in `synchronize'
activerecord (3.2.13) lib/active_record/attribute_methods.rb:63:in `define_attribute_methods'
activerecord (3.2.13) lib/active_record/attribute_methods.rb:168:in `respond_to?'
activesupport (3.2.13) lib/active_support/callbacks.rb:398:in `__run_callback'
activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_find_callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
activerecord (3.2.13) lib/active_record/base.rb:523:in `init_with'
activerecord (3.2.13) lib/active_record/inheritance.rb:68:in `instantiate'
activerecord (3.2.13) lib/active_record/querying.rb:38:in `block (2 levels) in find_by_sql'
activerecord (3.2.13) lib/active_record/querying.rb:38:in `block in find_by_sql'
activerecord (3.2.13) lib/active_record/explain.rb:41:in `logging_query_plan'
activerecord (3.2.13) lib/active_record/querying.rb:37:in `find_by_sql'
activerecord (3.2.13) lib/active_record/relation.rb:171:in `exec_queries'
activerecord (3.2.13) lib/active_record/relation.rb:160:in `block in to_a'
activerecord (3.2.13) lib/active_record/explain.rb:34:in `logging_query_plan'
activerecord (3.2.13) lib/active_record/relation.rb:159:in `to_a'
activerecord (3.2.13) lib/active_record/relation/delegation.rb:8:in `rescue in each'
activerecord (3.2.13) lib/active_record/relation/delegation.rb:6:in `each'
app/views/management_objectives/_items.html.erb:30:in `_app_views_management_objectives__items_html_erb__2456651386413182339_56758500'
actionpack (3.2.13) lib/action_view/template.rb:145:in `block in render'
activesupport (3.2.13) lib/active_support/notifications.rb:125:in `instrument'
actionpack (3.2.13) lib/action_view/template.rb:143:in `render'
actionpack (3.2.13) lib/action_view/renderer/partial_renderer.rb:265:in `render_partial'
actionpack (3.2.13) lib/action_view/renderer/partial_renderer.rb:238:in `block in render'
actionpack (3.2.13) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.13) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionpack (3.2.13) lib/action_view/renderer/partial_renderer.rb:237:in `render'
actionpack (3.2.13) lib/action_view/renderer/renderer.rb:41:in `render_partial'
actionpack (3.2.13) lib/action_view/renderer/renderer.rb:15:in `render'
actionpack (3.2.13) lib/action_view/helpers/rendering_helper.rb:24:in `render'
app/views/management_objectives/index.html.erb:64:in `_app_views_management_objectives_index_html_erb__4056717196502282234_46342800'
actionpack (3.2.13) lib/action_view/template.rb:145:in `block in render'
activesupport (3.2.13) lib/active_support/notifications.rb:125:in `instrument'
actionpack (3.2.13) lib/action_view/template.rb:143:in `render'
actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:47:in `block (2 levels) in render_template'
actionpack (3.2.13) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.13) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:46:in `block in render_template'
actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:54:in `render_with_layout'
actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:45:in `render_template'
actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:18:in `render'
actionpack (3.2.13) lib/action_view/renderer/renderer.rb:36:in `render_template'
actionpack (3.2.13) lib/action_view/renderer/renderer.rb:17:in `render'
actionpack (3.2.13) lib/abstract_controller/rendering.rb:110:in `_render_template'
actionpack (3.2.13) lib/action_controller/metal/streaming.rb:225:in `_render_template'
actionpack (3.2.13) lib/abstract_controller/rendering.rb:103:in `render_to_body'
actionpack (3.2.13) lib/action_controller/metal/renderers.rb:28:in `render_to_body'
actionpack (3.2.13) lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
actionpack (3.2.13) lib/abstract_controller/rendering.rb:88:in `render'
actionpack (3.2.13) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
activesupport (3.2.13) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/home/tommy/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
activesupport (3.2.13) lib/active_support/core_ext/benchmark.rb:5:in `ms'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
activerecord (3.2.13) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:39:in `render'
wicked_pdf (0.9.6) lib/pdf_helper.rb:23:in `render_with_wicked_pdf'
actionpack (3.2.13) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (3.2.13) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (3.2.13) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.13) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.13) lib/active_support/callbacks.rb:425:in `_run__565611819153590293__process_action__1000043893493154013__callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.13) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
activerecord (3.2.13) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.13) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.13) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.13) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.13) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.13) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:36:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:612:in `call'
warden (1.2.1) lib/warden/manager.rb:35:in `block in call'
warden (1.2.1) lib/warden/manager.rb:34:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.5) lib/rack/etag.rb:23:in `call'
rack (1.4.5) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/cookies.rb:341:in `call'
activerecord (3.2.13) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `_run__4036826611890793859__call__3734749657817228653__callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
better_errors (0.9.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (0.9.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (0.9.0) lib/better_errors/middleware.rb:56:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.13) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.13) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.13) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.13) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.5) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.13) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.5) lib/rack/lock.rb:15:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/static.rb:63:in `call'
railties (3.2.13) lib/rails/engine.rb:479:in `call'
railties (3.2.13) lib/rails/application.rb:223:in `call'
rack (1.4.5) lib/rack/content_length.rb:14:in `call'
railties (3.2.13) lib/rails/rack/log_tailer.rb:17:in `call'
thin (1.5.1) lib/thin/connection.rb:81:in `block in pre_process'
thin (1.5.1) lib/thin/connection.rb:79:in `pre_process'
thin (1.5.1) lib/thin/connection.rb:54:in `process'
thin (1.5.1) lib/thin/connection.rb:39:in `receive_data'
eventmachine (1.0.3) lib/eventmachine.rb:187:in `run'
thin (1.5.1) lib/thin/backends/base.rb:63:in `start'
thin (1.5.1) lib/thin/server.rb:159:in `start'
rack (1.4.5) lib/rack/handler/thin.rb:13:in `run'
rack (1.4.5) lib/rack/server.rb:268:in `start'
railties (3.2.13) lib/rails/commands/server.rb:70:in `start'
railties (3.2.13) lib/rails/commands.rb:55:in `block in <top (required)>'
railties (3.2.13) lib/rails/commands.rb:50:in `<top (required)>'
script/rails:6:in `<top (required)>'
ruby-debug-ide (0.4.17.beta14) lib/ruby-debug-ide.rb:127:in `debug_program'
ruby-debug-ide (0.4.17.beta14) bin/rdebug-ide:118:in `<top (required)>'
-e:1:in `<main>'
script/rails:0:in `<main>'
更新2
相关视图。 注意:,错误与特定视图无关,它发生在访问帐户项目集合的所有视图中
manage_objectices / _items.html.erb:
<table class="products-table">
<% if items.count > 0 %>
<thead>
<tr>
<th><%= sortable_objectives "title", t(:'activerecord.attributes.item.title'),
sort_param_name, direction_param_name %></th>
<th><%= sortable_objectives "visits", t(:'activerecord.attributes.item.visits'),
sort_param_name, direction_param_name %></th>
<th><%= sortable_objectives "sales", t(:'activerecord.attributes.item.sold_quantity'),
sort_param_name, direction_param_name %></th>
<th><%=sortable_objectives "questions", t(:'activerecord.models.question.other'),
sort_param_name, direction_param_name %></th>
<th><%=sortable_objectives "conversions", t(:'private.orders.statistics.management_objectives.conversions'),
sort_param_name, direction_param_name %></th>
<th><%=sortable_objectives "question_rates", t(:'private.orders.statistics.management_objectives.question_rate'),
sort_param_name, direction_param_name %></th>
<th><%=sortable_objectives "objectives", t(:'private.orders.statistics.management_objectives.objectives'),
sort_param_name, direction_param_name %></th>
<th><%=sortable_objectives "successful_rates", t(:'private.orders.statistics.management_objectives.successful_rates'),
sort_param_name, direction_param_name %></th>
</tr>
</thead>
<tbody>
<% items.each do |item| %>
<%= render :partial => "single_item", :locals => {:item => item} %>
<% end %>
</tbody>
<% else %>
<%= t(:'private.items.no_items')%>
<% end %>
</table>
<%= paginate items, :theme => "mercadopro", :param_name => page_param_name, :params => {:tab => page_param_name} %>
management_objectives / _items.html.erb:
<tr>
<td class="info">
<h3><span class="fade"></span><%= link_to item.title, mercadopro_account_account_item_path(current_mercadopro_account,current_account,item.id) %> </h3>
<p>#<%= item.ml_id %> | <%= item_listing_type(item) %> | <%= item_ends_in(item) %> </p>
</td>
<td class="number">
<%= item.visits %>
</td>
<td class="number">
<%= item.sold_quantity %>
</td>
<td class="number">
<%= item.questions.count%>
</td>
<td class="number">
<%= number_to_percentage(item.conversions_percentage)%>
</td>
<td class="number">
<%= number_to_percentage(item.question_rate)%>
</td>
<td class="number">
<%= item.available_quantity%>
</td>
<td class="number">
<%= number_to_percentage(item.objective_accomplished_percentage)%>
</td>
</tr>
谢谢!