我已经将activeadmin安装到我的ruby-on-rails项目中。除了一个,我可以看到每个模型。当我在标题栏中点击此模型的链接时,我得到一个错误的说法:
undefined method `to_sym' for nil:NilClass
Extracted source (around line #2):
insert_tag renderer_for(:index)
不起作用的模型是唯一具有多次通过关系的模型。以下是模型的代码:
class Project < ActiveRecord::Base
belongs_to :person
belongs_to :regularity
has_many :groupings
has_many :groups, through: :groupings
has_many :localizations
has_many :locations, through: :localizations
has_many :categorizations
has_many :kategorien, through: :categorizations
has_many :agings
has_many :ages, through: :agings
accepts_nested_attributes_for :groupings
accepts_nested_attributes_for :localizations
accepts_nested_attributes_for :categorizations
accepts_nested_attributes_for :agings
accepts_nested_attributes_for :groups
accepts_nested_attributes_for :locations
accepts_nested_attributes_for :kategorien
accepts_nested_attributes_for :ages
def LinkToKategorie (arr)
arr.each do |kat|
Categorization.create(kategorie: kat, project: self)
end
end
def LinkToLocation (arr)
arr.each do |loc|
Localization.create(location: loc, project: self)
end
end
def LinkToGroup (arr)
arr.each do |gro|
Grouping.create(group: gro, project: self)
end
end
def LinkToAge (arr)
arr.each do |ag|
Aging.create(age: ag, project: self)
end
end
end
以下是错误的完整描述:
activerecord (4.1.8) lib/active_record/reflection.rb:100:in `_reflect_on_association'
activerecord (4.1.8) lib/active_record/reflection.rb:537:in `source_reflection'
activerecord (4.1.8) lib/active_record/reflection.rb:575:in `chain'
/home/oscar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-988b34e77d1f/lib/active_admin/filters/resource_extension.rb:131:in `block in default_association_filters'
/home/oscar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-988b34e77d1f/lib/active_admin/filters/resource_extension.rb:131:in `reject!'
/home/oscar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-988b34e77d1f/lib/active_admin/filters/resource_extension.rb:131:in `default_association_filters'
/home/oscar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-988b34e77d1f/lib/active_admin/filters/resource_extension.rb:111:in `default_filters'
/home/oscar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-988b34e77d1f/lib/active_admin/filters/resource_extension.rb:96:in `filter_lookup'
/home/oscar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-988b34e77d1f/lib/active_admin/filters/resource_extension.rb:25:in `filters'
/home/oscar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-988b34e77d1f/lib/active_admin/filters/resource_extension.rb:154:in `block in filters_sidebar_section'
/home/oscar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-988b34e77d1f/lib/active_admin/helpers/optional_display.rb:25:in `instance_exec'
/home/oscar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-988b34e77d1f/lib/active_admin/helpers/optional_display.rb:25:in `display_on?'
/home/oscar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-988b34e77d1f/lib/active_admin/resource/sidebars.rb:17:in `block in sidebar_sections_for'
/home/oscar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-988b34e77d1f/lib/active_admin/resource/sidebars.rb:17:in `select'
/home/oscar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-988b34e77d1f/lib/active_admin/resource/sidebars.rb:17:in `sidebar_sections_for'
/home/oscar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-988b34e77d1f/lib/active_admin/views/pages/base.rb:112:in `sidebar_sections_for_action'
/home/oscar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-988b34e77d1f/lib/active_admin/views/pages/base.rb:136:in `skip_sidebar?'
/home/oscar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-988b34e77d1f/lib/active_admin/views/pages/base.rb:74:in `build_page_content'
/home/oscar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-988b34e77d1f/lib/active_admin/views/pages/base.rb:52:in `block (2 levels) in build_page'
arbre (1.0.3) lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
arbre (1.0.3) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.3) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
arbre (1.0.3) lib/arbre/element/builder_methods.rb:26:in `build_tag'
arbre (1.0.3) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
arbre (1.0.3) lib/arbre/element/builder_methods.rb:14:in `div'
/home/oscar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-988b34e77d1f/lib/active_admin/views/pages/base.rb:48:in `block in build_page'
arbre (1.0.3) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.3) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
/home/oscar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-988b34e77d1f/lib/active_admin/views/pages/base.rb:47:in `build_page'
/home/oscar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-988b34e77d1f/lib/active_admin/views/pages/base.rb:10:in `build'
arbre (1.0.3) lib/arbre/element/builder_methods.rb:30:in `block in build_tag'
arbre (1.0.3) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.3) lib/arbre/element/builder_methods.rb:26:in `build_tag'
arbre (1.0.3) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
/home/oscar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-988b34e77d1f/app/views/active_admin/resource/index.html.arb:2:in `block in __home_oscar__rbenv_versions_______lib_ruby_gems_______bundler_gems_activeadmin____b__e__d_f_app_views_active_admin_resource_index_html_arb___4298410947655854879_70101451315680'
arbre (1.0.3) lib/arbre/context.rb:45:in `instance_eval'
arbre (1.0.3) lib/arbre/context.rb:45:in `initialize'
/home/oscar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-988b34e77d1f/app/views/active_admin/resource/index.html.arb:1:in `new'
/home/oscar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-988b34e77d1f/app/views/active_admin/resource/index.html.arb:1:in `__home_oscar__rbenv_versions_______lib_ruby_gems_______bundler_gems_activeadmin____b__e__d_f_app_views_active_admin_resource_index_html_arb___4298410947655854879_70101451315680'
actionview (4.1.8) lib/action_view/template.rb:145:in `block in render'
activesupport (4.1.8) lib/active_support/notifications.rb:161:in `instrument'
actionview (4.1.8) lib/action_view/template.rb:339:in `instrument'
actionview (4.1.8) lib/action_view/template.rb:143:in `render'
actionview (4.1.8) lib/action_view/renderer/template_renderer.rb:55:in `block (2 levels) in render_template'
actionview (4.1.8) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (4.1.8) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.8) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.8) lib/active_support/notifications.rb:159:in `instrument'
actionview (4.1.8) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionview (4.1.8) lib/action_view/renderer/template_renderer.rb:54:in `block in render_template'
actionview (4.1.8) lib/action_view/renderer/template_renderer.rb:62:in `render_with_layout'
actionview (4.1.8) lib/action_view/renderer/template_renderer.rb:53:in `render_template'
actionview (4.1.8) lib/action_view/renderer/template_renderer.rb:17:in `render'
actionview (4.1.8) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionview (4.1.8) lib/action_view/renderer/renderer.rb:23:in `render'
actionview (4.1.8) lib/action_view/rendering.rb:99:in `_render_template'
actionpack (4.1.8) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (4.1.8) lib/action_view/rendering.rb:82:in `render_to_body'
actionpack (4.1.8) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
actionpack (4.1.8) lib/action_controller/metal/renderers.rb:32:in `render_to_body'
actionpack (4.1.8) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (4.1.8) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.1.8) lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
activesupport (4.1.8) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/home/oscar/.rbenv/versions/2.2.3/lib/ruby/2.2.0/benchmark.rb:303:in `realtime'
activesupport (4.1.8) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.1.8) lib/action_controller/metal/instrumentation.rb:41:in `block in render'
actionpack (4.1.8) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
activerecord (4.1.8) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.1.8) lib/action_controller/metal/instrumentation.rb:40:in `render'
actionpack (4.1.8) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (4.1.8) lib/action_controller/metal/responder.rb:238:in `default_render'
actionpack (4.1.8) lib/action_controller/metal/responder.rb:165:in `to_html'
responders (1.1.2) lib/responders/flash_responder.rb:107:in `to_html'
actionpack (4.1.8) lib/action_controller/metal/responder.rb:158:in `respond'
actionpack (4.1.8) lib/action_controller/metal/responder.rb:151:in `call'
actionpack (4.1.8) lib/action_controller/metal/mime_responds.rb:400:in `respond_with'
inherited_resources (1.6.0) lib/inherited_resources/actions.rb:7:in `index'
/home/oscar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/activeadmin-988b34e77d1f/lib/active_admin/resource_controller/streaming.rb:12:in `index'
actionpack (4.1.8) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.1.8) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.1.8) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.1.8) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.1.8) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.8) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.8) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.8) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.8) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.8) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.8) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.8) lib/active_support/callbacks.rb:229:in `call'
activesupport (4.1.8) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.8) lib/active_support/callbacks.rb:229:in `call'
activesupport (4.1.8) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.8) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.8) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.8) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.8) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.8) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.8) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.8) lib/active_support/callbacks.rb:86:in `call'
activesupport (4.1.8) lib/active_support/callbacks.rb:86:in `run_callbacks'
actionpack (4.1.8) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.1.8) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.1.8) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.1.8) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.8) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.8) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.1.8) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.1.8) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.1.8) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.1.8) lib/abstract_controller/base.rb:136:in `process'
actionview (4.1.8) lib/action_view/rendering.rb:30:in `process'
actionpack (4.1.8) lib/action_controller/metal.rb:196:in `dispatch'
actionpack (4.1.8) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.1.8) lib/action_controller/metal.rb:232:in `block in action'
actionpack (4.1.8) lib/action_dispatch/routing/route_set.rb:82:in `call'
actionpack (4.1.8) lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
actionpack (4.1.8) lib/action_dispatch/routing/route_set.rb:50:in `call'
actionpack (4.1.8) lib/action_dispatch/journey/router.rb:73:in `block in call'
actionpack (4.1.8) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.1.8) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.8) lib/action_dispatch/routing/route_set.rb:678:in `call'
warden (1.2.6) lib/warden/manager.rb:35:in `block in call'
warden (1.2.6) lib/warden/manager.rb:34:in `catch'
warden (1.2.6) lib/warden/manager.rb:34:in `call'
rack (1.5.5) lib/rack/etag.rb:23:in `call'
rack (1.5.5) lib/rack/conditionalget.rb:25:in `call'
rack (1.5.5) lib/rack/head.rb:11:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/flash.rb:254:in `call'
rack (1.5.5) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.5) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.1.8) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.1.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
activerecord (4.1.8) lib/active_record/migration.rb:380:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.8) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.8) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.8) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.8) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.8) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.8) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.8) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.8) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.5) lib/rack/runtime.rb:17:in `call'
activesupport (4.1.8) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.5) lib/rack/lock.rb:17:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/static.rb:84:in `call'
rack (1.5.5) lib/rack/sendfile.rb:112:in `call'
railties (4.1.8) lib/rails/engine.rb:514:in `call'
railties (4.1.8) lib/rails/application.rb:144:in `call'
rack (1.5.5) lib/rack/content_length.rb:14:in `call'
puma (2.15.3) lib/puma/server.rb:541:in `handle_request'
puma (2.15.3) lib/puma/server.rb:388:in `process_client'
puma (2.15.3) lib/puma/server.rb:270:in `block in run'
puma (2.15.3) lib/puma/thread_pool.rb:106:in `call'
puma (2.15.3) lib/puma/thread_pool.rb:106:in `block in spawn_thread'
当我单击activeadmin仪表板的headbar中的Project链接时,会发生错误。头条中的每个其他链接都在列表视图中显示模型的数据。只有这个模型不起作用。
答案 0 :(得分:0)
我怀疑其中一个arr
包含零值。如果适用,请在将compact
传递给方法之前使用arr.compact.each
:
delivery-slip.tpl