railsadminteam / rails_admin

RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data
MIT License
7.89k stars 2.26k forks source link

Work with @bindings is not thread-safe #2942

Closed romikoops closed 5 years ago

romikoops commented 7 years ago

I use rails 5.1 application with Puma as a web server by default. I have loosing original value of @bindings on opening for edit an entity with big amount of associated records (it is core feature of my app). I tried to debug and see the problem happens here https://github.com/sferik/rails_admin/blob/master/lib/rails_admin/config/proxyable/proxy.rb#L22

When I start my web application with single thread, I never had exception

RAILS_MAX_THREADS=1 rails server

When I start it by default with 5 threads, then it randomly generates this error:

Error message:  undefined method `[]' for nil:NilClass
URL:  GET https://myapp.com/admin/ordinary_event/7/edit
FILE: [GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/lib/rails_admin/config/fields/base.rb:328

[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/lib/rails_admin/config/fields/base.rb:328 in form_default_value
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/views/rails_admin/main/_form_filtering_select.html.haml:28 in _vendor_bundle_ruby_______bundler_gems_rails_admin_c____fee___e_app_views_rails_admin_main__form_filtering_select_html_haml___2686669982090751798_6989499418[Truncated]
/gems/actionview-5.1.4/lib/action_view/template.rb:157 in block in render
/gems/activesupport-5.1.4/lib/active_support/notifications.rb:168 in instrument
/gems/actionview-5.1.4/lib/action_view/template.rb:352 in instrument_render_template
/gems/actionview-5.1.4/lib/action_view/template.rb:155 in render
/gems/actionview-5.1.4/lib/action_view/renderer/partial_renderer.rb:342 in block in render_partial
/gems/actionview-5.1.4/lib/action_view/renderer/abstract_renderer.rb:42 in block in instrument
/gems/activesupport-5.1.4/lib/active_support/notifications.rb:166 in block in instrument
/gems/activesupport-5.1.4/lib/active_support/notifications/instrumenter.rb:21 in instrument
/gems/activesupport-5.1.4/lib/active_support/notifications.rb:166 in instrument
/gems/actionview-5.1.4/lib/action_view/renderer/abstract_renderer.rb:41 in instrument
/gems/actionview-5.1.4/lib/action_view/renderer/partial_renderer.rb:331 in render_partial
/gems/scout_apm-2.1.30/lib/scout_apm/tracer.rb:72 in block in render_partial_with_scout_instrument
/gems/scout_apm-2.1.30/lib/scout_apm/tracer.rb:35 in instrument
/gems/scout_apm-2.1.30/lib/scout_apm/tracer.rb:68 in render_partial_with_scout_instrument
/gems/actionview-5.1.4/lib/action_view/renderer/partial_renderer.rb:310 in render
/gems/actionview-5.1.4/lib/action_view/renderer/renderer.rb:47 in render_partial
/gems/actionview-5.1.4/lib/action_view/renderer/renderer.rb:21 in render
/gems/actionview-5.1.4/lib/action_view/helpers/rendering_helper.rb:32 in render
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:12 in block in render
/gems/haml-5.0.3/lib/haml/helpers.rb:92 in non_haml
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:12 in render
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/lib/rails_admin/config/fields/base.rb:227 in block in <class:Base>
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/lib/rails_admin/config/configurable.rb:66 in instance_eval
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/lib/rails_admin/config/configurable.rb:66 in block in register_instance_option
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/lib/rails_admin/config/proxyable/proxy.rb:27 in method_missing
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:73 in field_for
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:58 in block in input_for
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in block in capture
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:203 in with_output_buffer
/gems/haml-5.0.3/lib/haml/helpers/action_view_xss_mods.rb:6 in with_output_buffer_with_haml_xss
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in capture
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:47 in capture_with_haml
/gems/actionview-5.1.4/lib/action_view/helpers/tag_helper.rb:272 in content_tag
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:66 in content_tag_with_haml
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:57 in input_for
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:46 in block in field_wrapper_for
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in block in capture
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:203 in with_output_buffer
/gems/haml-5.0.3/lib/haml/helpers/action_view_xss_mods.rb:6 in with_output_buffer_with_haml_xss
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in capture
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:47 in capture_with_haml
/gems/actionview-5.1.4/lib/action_view/helpers/tag_helper.rb:272 in content_tag
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:66 in content_tag_with_haml
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:44 in field_wrapper_for
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:35 in block (2 levels) in fieldset_for
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:35 in collect
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:35 in block in fieldset_for
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in block in capture
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:203 in with_output_buffer
/gems/haml-5.0.3/lib/haml/helpers/action_view_xss_mods.rb:6 in with_output_buffer_with_haml_xss
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in capture
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:47 in capture_with_haml
/gems/actionview-5.1.4/lib/action_view/helpers/tag_helper.rb:272 in content_tag
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:66 in content_tag_with_haml
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:31 in fieldset_for
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:16 in block (2 levels) in generate
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:15 in collect
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:15 in block in generate
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:131 in without_field_error_proc_added_div
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:7 in generate
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/views/rails_admin/main/_form_nested_many.html.haml:15 in block in _vendor_bundle_ruby_______bundler_gems_rails_admin_c____fee___e_app_views_rails_admin_main__form_nested_many_html_haml___737446093266459406_6989489[Truncated]
/gems/haml-5.0.3/lib/haml/helpers.rb:382 in block in capture_haml
/gems/haml-5.0.3/lib/haml/helpers.rb:667 in with_haml_buffer
/gems/haml-5.0.3/lib/haml/helpers.rb:378 in capture_haml
/gems/haml-5.0.3/lib/haml/helpers/xss_mods.rb:62 in capture_haml_with_haml_xss
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:45 in capture_with_haml
/gems/actionview-5.1.4/lib/action_view/helpers/form_helper.rb:2330 in block in fields_for_nested_model
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in block in capture
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:203 in with_output_buffer
/gems/haml-5.0.3/lib/haml/helpers/action_view_xss_mods.rb:6 in with_output_buffer_with_haml_xss
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in capture
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:47 in capture_with_haml
/gems/actionview-5.1.4/lib/action_view/helpers/form_helper.rb:1012 in fields_for
/gems/actionview-5.1.4/lib/action_view/helpers/form_helper.rb:2329 in fields_for_nested_model
/gems/nested_form-0.3.2/lib/nested_form/builder_mixin.rb:98 in fields_for_nested_model
/gems/actionview-5.1.4/lib/action_view/helpers/form_helper.rb:2315 in block in fields_for_with_nested_attributes
/gems/activerecord-5.1.4/lib/active_record/relation/delegation.rb:39 in each
/gems/activerecord-5.1.4/lib/active_record/relation/delegation.rb:39 in each
/gems/actionview-5.1.4/lib/action_view/helpers/form_helper.rb:2309 in fields_for_with_nested_attributes
/gems/nested_form-0.3.2/lib/nested_form/builder_mixin.rb:87 in fields_for_with_nested_attributes
/gems/actionview-5.1.4/lib/action_view/helpers/form_helper.rb:1954 in fields_for
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/views/rails_admin/main/_form_nested_many.html.haml:12 in _vendor_bundle_ruby_______bundler_gems_rails_admin_c____fee___e_app_views_rails_admin_main__form_nested_many_html_haml___737446093266459406_69894893088400
/gems/actionview-5.1.4/lib/action_view/template.rb:157 in block in render
/gems/activesupport-5.1.4/lib/active_support/notifications.rb:168 in instrument
/gems/actionview-5.1.4/lib/action_view/template.rb:352 in instrument_render_template
/gems/actionview-5.1.4/lib/action_view/template.rb:155 in render
/gems/actionview-5.1.4/lib/action_view/renderer/partial_renderer.rb:342 in block in render_partial
/gems/actionview-5.1.4/lib/action_view/renderer/abstract_renderer.rb:42 in block in instrument
/gems/activesupport-5.1.4/lib/active_support/notifications.rb:166 in block in instrument
/gems/activesupport-5.1.4/lib/active_support/notifications/instrumenter.rb:21 in instrument
/gems/activesupport-5.1.4/lib/active_support/notifications.rb:166 in instrument
/gems/actionview-5.1.4/lib/action_view/renderer/abstract_renderer.rb:41 in instrument
/gems/actionview-5.1.4/lib/action_view/renderer/partial_renderer.rb:331 in render_partial
/gems/scout_apm-2.1.30/lib/scout_apm/tracer.rb:72 in block in render_partial_with_scout_instrument
/gems/scout_apm-2.1.30/lib/scout_apm/tracer.rb:35 in instrument
/gems/scout_apm-2.1.30/lib/scout_apm/tracer.rb:68 in render_partial_with_scout_instrument
/gems/actionview-5.1.4/lib/action_view/renderer/partial_renderer.rb:310 in render
/gems/actionview-5.1.4/lib/action_view/renderer/renderer.rb:47 in render_partial
/gems/actionview-5.1.4/lib/action_view/renderer/renderer.rb:21 in render
/gems/actionview-5.1.4/lib/action_view/helpers/rendering_helper.rb:32 in render
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:12 in block in render
/gems/haml-5.0.3/lib/haml/helpers.rb:92 in non_haml
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:12 in render
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/lib/rails_admin/config/fields/base.rb:227 in block in <class:Base>
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/lib/rails_admin/config/configurable.rb:66 in instance_eval
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/lib/rails_admin/config/configurable.rb:66 in block in register_instance_option
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/lib/rails_admin/config/proxyable/proxy.rb:27 in method_missing
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:73 in field_for
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:46 in block in field_wrapper_for
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in block in capture
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:203 in with_output_buffer
/gems/haml-5.0.3/lib/haml/helpers/action_view_xss_mods.rb:6 in with_output_buffer_with_haml_xss
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in capture
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:47 in capture_with_haml
/gems/actionview-5.1.4/lib/action_view/helpers/tag_helper.rb:272 in content_tag
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:66 in content_tag_with_haml
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:44 in field_wrapper_for
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:35 in block (2 levels) in fieldset_for
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:35 in collect
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:35 in block in fieldset_for
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in block in capture
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:203 in with_output_buffer
/gems/haml-5.0.3/lib/haml/helpers/action_view_xss_mods.rb:6 in with_output_buffer_with_haml_xss
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in capture
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:47 in capture_with_haml
/gems/actionview-5.1.4/lib/action_view/helpers/tag_helper.rb:272 in content_tag
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:66 in content_tag_with_haml
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:31 in fieldset_for
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:16 in block (2 levels) in generate
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:15 in collect
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:15 in block in generate
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:131 in without_field_error_proc_added_div
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:7 in generate
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/views/rails_admin/main/_form_nested_one.html.haml:17 in block in _vendor_bundle_ruby_______bundler_gems_rails_admin_c____fee___e_app_views_rails_admin_main__form_nested_one_html_haml___3732433452303815904_6989499[Truncated]
/gems/haml-5.0.3/lib/haml/helpers.rb:382 in block in capture_haml
/gems/haml-5.0.3/lib/haml/helpers.rb:667 in with_haml_buffer
/gems/haml-5.0.3/lib/haml/helpers.rb:378 in capture_haml
/gems/haml-5.0.3/lib/haml/helpers/xss_mods.rb:62 in capture_haml_with_haml_xss
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:45 in capture_with_haml
/gems/actionview-5.1.4/lib/action_view/helpers/form_helper.rb:2330 in block in fields_for_nested_model
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in block in capture
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:203 in with_output_buffer
/gems/haml-5.0.3/lib/haml/helpers/action_view_xss_mods.rb:6 in with_output_buffer_with_haml_xss
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in capture
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:47 in capture_with_haml
/gems/actionview-5.1.4/lib/action_view/helpers/form_helper.rb:1012 in fields_for
/gems/actionview-5.1.4/lib/action_view/helpers/form_helper.rb:2329 in fields_for_nested_model
/gems/nested_form-0.3.2/lib/nested_form/builder_mixin.rb:98 in fields_for_nested_model
/gems/actionview-5.1.4/lib/action_view/helpers/form_helper.rb:2319 in fields_for_with_nested_attributes
/gems/nested_form-0.3.2/lib/nested_form/builder_mixin.rb:87 in fields_for_with_nested_attributes
/gems/actionview-5.1.4/lib/action_view/helpers/form_helper.rb:1954 in fields_for
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/views/rails_admin/main/_form_nested_one.html.haml:14 in _vendor_bundle_ruby_______bundler_gems_rails_admin_c____fee___e_app_views_rails_admin_main__form_nested_one_html_haml___3732433452303815904_69894992172040
/gems/actionview-5.1.4/lib/action_view/template.rb:157 in block in render
/gems/activesupport-5.1.4/lib/active_support/notifications.rb:168 in instrument
Caused by NoMethodError: undefined method `[]' for nil:NilClass
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/lib/rails_admin/config/fields/base.rb:328 in form_default_value
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/views/rails_admin/main/_form_filtering_select.html.haml:28 in _vendor_bundle_ruby_______bundler_gems_rails_admin_c____fee___e_app_views_rails_admin_main__form_filtering_select_html_haml___2686669982090751798_6989499418[Truncated]
/gems/actionview-5.1.4/lib/action_view/template.rb:157 in block in render
/gems/activesupport-5.1.4/lib/active_support/notifications.rb:168 in instrument
/gems/actionview-5.1.4/lib/action_view/template.rb:352 in instrument_render_template
/gems/actionview-5.1.4/lib/action_view/template.rb:155 in render
/gems/actionview-5.1.4/lib/action_view/renderer/partial_renderer.rb:342 in block in render_partial
/gems/actionview-5.1.4/lib/action_view/renderer/abstract_renderer.rb:42 in block in instrument
/gems/activesupport-5.1.4/lib/active_support/notifications.rb:166 in block in instrument
/gems/activesupport-5.1.4/lib/active_support/notifications/instrumenter.rb:21 in instrument
/gems/activesupport-5.1.4/lib/active_support/notifications.rb:166 in instrument
/gems/actionview-5.1.4/lib/action_view/renderer/abstract_renderer.rb:41 in instrument
/gems/actionview-5.1.4/lib/action_view/renderer/partial_renderer.rb:331 in render_partial
/gems/scout_apm-2.1.30/lib/scout_apm/tracer.rb:72 in block in render_partial_with_scout_instrument
/gems/scout_apm-2.1.30/lib/scout_apm/tracer.rb:35 in instrument
/gems/scout_apm-2.1.30/lib/scout_apm/tracer.rb:68 in render_partial_with_scout_instrument
/gems/actionview-5.1.4/lib/action_view/renderer/partial_renderer.rb:310 in render
/gems/actionview-5.1.4/lib/action_view/renderer/renderer.rb:47 in render_partial
/gems/actionview-5.1.4/lib/action_view/renderer/renderer.rb:21 in render
/gems/actionview-5.1.4/lib/action_view/helpers/rendering_helper.rb:32 in render
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:12 in block in render
/gems/haml-5.0.3/lib/haml/helpers.rb:92 in non_haml
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:12 in render
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/lib/rails_admin/config/fields/base.rb:227 in block in <class:Base>
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/lib/rails_admin/config/configurable.rb:66 in instance_eval
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/lib/rails_admin/config/configurable.rb:66 in block in register_instance_option
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/lib/rails_admin/config/proxyable/proxy.rb:27 in method_missing
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:73 in field_for
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:58 in block in input_for
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in block in capture
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:203 in with_output_buffer
/gems/haml-5.0.3/lib/haml/helpers/action_view_xss_mods.rb:6 in with_output_buffer_with_haml_xss
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in capture
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:47 in capture_with_haml
/gems/actionview-5.1.4/lib/action_view/helpers/tag_helper.rb:272 in content_tag
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:66 in content_tag_with_haml
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:57 in input_for
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:46 in block in field_wrapper_for
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in block in capture
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:203 in with_output_buffer
/gems/haml-5.0.3/lib/haml/helpers/action_view_xss_mods.rb:6 in with_output_buffer_with_haml_xss
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in capture
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:47 in capture_with_haml
/gems/actionview-5.1.4/lib/action_view/helpers/tag_helper.rb:272 in content_tag
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:66 in content_tag_with_haml
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:44 in field_wrapper_for
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:35 in block (2 levels) in fieldset_for
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:35 in collect
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:35 in block in fieldset_for
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in block in capture
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:203 in with_output_buffer
/gems/haml-5.0.3/lib/haml/helpers/action_view_xss_mods.rb:6 in with_output_buffer_with_haml_xss
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in capture
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:47 in capture_with_haml
/gems/actionview-5.1.4/lib/action_view/helpers/tag_helper.rb:272 in content_tag
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:66 in content_tag_with_haml
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:31 in fieldset_for
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:16 in block (2 levels) in generate
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:15 in collect
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:15 in block in generate
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:131 in without_field_error_proc_added_div
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:7 in generate
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/views/rails_admin/main/_form_nested_many.html.haml:15 in block in _vendor_bundle_ruby_______bundler_gems_rails_admin_c____fee___e_app_views_rails_admin_main__form_nested_many_html_haml___737446093266459406_6989489[Truncated]
/gems/haml-5.0.3/lib/haml/helpers.rb:382 in block in capture_haml
/gems/haml-5.0.3/lib/haml/helpers.rb:667 in with_haml_buffer
/gems/haml-5.0.3/lib/haml/helpers.rb:378 in capture_haml
/gems/haml-5.0.3/lib/haml/helpers/xss_mods.rb:62 in capture_haml_with_haml_xss
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:45 in capture_with_haml
/gems/actionview-5.1.4/lib/action_view/helpers/form_helper.rb:2330 in block in fields_for_nested_model
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in block in capture
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:203 in with_output_buffer
/gems/haml-5.0.3/lib/haml/helpers/action_view_xss_mods.rb:6 in with_output_buffer_with_haml_xss
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in capture
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:47 in capture_with_haml
/gems/actionview-5.1.4/lib/action_view/helpers/form_helper.rb:1012 in fields_for
/gems/actionview-5.1.4/lib/action_view/helpers/form_helper.rb:2329 in fields_for_nested_model
/gems/nested_form-0.3.2/lib/nested_form/builder_mixin.rb:98 in fields_for_nested_model
/gems/actionview-5.1.4/lib/action_view/helpers/form_helper.rb:2315 in block in fields_for_with_nested_attributes
/gems/activerecord-5.1.4/lib/active_record/relation/delegation.rb:39 in each
/gems/activerecord-5.1.4/lib/active_record/relation/delegation.rb:39 in each
/gems/actionview-5.1.4/lib/action_view/helpers/form_helper.rb:2309 in fields_for_with_nested_attributes
/gems/nested_form-0.3.2/lib/nested_form/builder_mixin.rb:87 in fields_for_with_nested_attributes
/gems/actionview-5.1.4/lib/action_view/helpers/form_helper.rb:1954 in fields_for
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/views/rails_admin/main/_form_nested_many.html.haml:12 in _vendor_bundle_ruby_______bundler_gems_rails_admin_c____fee___e_app_views_rails_admin_main__form_nested_many_html_haml___737446093266459406_69894893088400
/gems/actionview-5.1.4/lib/action_view/template.rb:157 in block in render
/gems/activesupport-5.1.4/lib/active_support/notifications.rb:168 in instrument
/gems/actionview-5.1.4/lib/action_view/template.rb:352 in instrument_render_template
/gems/actionview-5.1.4/lib/action_view/template.rb:155 in render
/gems/actionview-5.1.4/lib/action_view/renderer/partial_renderer.rb:342 in block in render_partial
/gems/actionview-5.1.4/lib/action_view/renderer/abstract_renderer.rb:42 in block in instrument
/gems/activesupport-5.1.4/lib/active_support/notifications.rb:166 in block in instrument
/gems/activesupport-5.1.4/lib/active_support/notifications/instrumenter.rb:21 in instrument
/gems/activesupport-5.1.4/lib/active_support/notifications.rb:166 in instrument
/gems/actionview-5.1.4/lib/action_view/renderer/abstract_renderer.rb:41 in instrument
/gems/actionview-5.1.4/lib/action_view/renderer/partial_renderer.rb:331 in render_partial
/gems/scout_apm-2.1.30/lib/scout_apm/tracer.rb:72 in block in render_partial_with_scout_instrument
/gems/scout_apm-2.1.30/lib/scout_apm/tracer.rb:35 in instrument
/gems/scout_apm-2.1.30/lib/scout_apm/tracer.rb:68 in render_partial_with_scout_instrument
/gems/actionview-5.1.4/lib/action_view/renderer/partial_renderer.rb:310 in render
/gems/actionview-5.1.4/lib/action_view/renderer/renderer.rb:47 in render_partial
/gems/actionview-5.1.4/lib/action_view/renderer/renderer.rb:21 in render
/gems/actionview-5.1.4/lib/action_view/helpers/rendering_helper.rb:32 in render
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:12 in block in render
/gems/haml-5.0.3/lib/haml/helpers.rb:92 in non_haml
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:12 in render
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/lib/rails_admin/config/fields/base.rb:227 in block in <class:Base>
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/lib/rails_admin/config/configurable.rb:66 in instance_eval
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/lib/rails_admin/config/configurable.rb:66 in block in register_instance_option
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/lib/rails_admin/config/proxyable/proxy.rb:27 in method_missing
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:73 in field_for
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:46 in block in field_wrapper_for
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in block in capture
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:203 in with_output_buffer
/gems/haml-5.0.3/lib/haml/helpers/action_view_xss_mods.rb:6 in with_output_buffer_with_haml_xss
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in capture
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:47 in capture_with_haml
/gems/actionview-5.1.4/lib/action_view/helpers/tag_helper.rb:272 in content_tag
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:66 in content_tag_with_haml
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:44 in field_wrapper_for
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:35 in block (2 levels) in fieldset_for
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:35 in collect
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:35 in block in fieldset_for
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in block in capture
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:203 in with_output_buffer
/gems/haml-5.0.3/lib/haml/helpers/action_view_xss_mods.rb:6 in with_output_buffer_with_haml_xss
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in capture
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:47 in capture_with_haml
/gems/actionview-5.1.4/lib/action_view/helpers/tag_helper.rb:272 in content_tag
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:66 in content_tag_with_haml
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:31 in fieldset_for
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:16 in block (2 levels) in generate
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:15 in collect
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:15 in block in generate
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:131 in without_field_error_proc_added_div
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/helpers/rails_admin/form_builder.rb:7 in generate
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/views/rails_admin/main/_form_nested_one.html.haml:17 in block in _vendor_bundle_ruby_______bundler_gems_rails_admin_c____fee___e_app_views_rails_admin_main__form_nested_one_html_haml___3732433452303815904_6989499[Truncated]
/gems/haml-5.0.3/lib/haml/helpers.rb:382 in block in capture_haml
/gems/haml-5.0.3/lib/haml/helpers.rb:667 in with_haml_buffer
/gems/haml-5.0.3/lib/haml/helpers.rb:378 in capture_haml
/gems/haml-5.0.3/lib/haml/helpers/xss_mods.rb:62 in capture_haml_with_haml_xss
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:45 in capture_with_haml
/gems/actionview-5.1.4/lib/action_view/helpers/form_helper.rb:2330 in block in fields_for_nested_model
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in block in capture
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:203 in with_output_buffer
/gems/haml-5.0.3/lib/haml/helpers/action_view_xss_mods.rb:6 in with_output_buffer_with_haml_xss
/gems/actionview-5.1.4/lib/action_view/helpers/capture_helper.rb:39 in capture
/gems/haml-5.0.3/lib/haml/helpers/action_view_mods.rb:47 in capture_with_haml
/gems/actionview-5.1.4/lib/action_view/helpers/form_helper.rb:1012 in fields_for
/gems/actionview-5.1.4/lib/action_view/helpers/form_helper.rb:2329 in fields_for_nested_model
/gems/nested_form-0.3.2/lib/nested_form/builder_mixin.rb:98 in fields_for_nested_model
/gems/actionview-5.1.4/lib/action_view/helpers/form_helper.rb:2319 in fields_for_with_nested_attributes
/gems/nested_form-0.3.2/lib/nested_form/builder_mixin.rb:87 in fields_for_with_nested_attributes
/gems/actionview-5.1.4/lib/action_view/helpers/form_helper.rb:1954 in fields_for
[GEM_ROOT]/bundler/gems/rails_admin-c3794fee412e/app/views/rails_admin/main/_form_nested_one.html.haml:14 in _vendor_bundle_ruby_______bundler_gems_rails_admin_c____fee___e_app_views_rails_admin_main__form_nested_one_html_haml___3732433452303815904_69894992172040
/gems/actionview-5.1.4/lib/action_view/template.rb:157 in block in render
/gems/activesupport-5.1.4/lib/active_support/notifications.rb:168 in instrument
Parameters
{
  "action": "edit",
  "controller": "rails_admin/main",
  "id": "7",
  "model_name": "ordinary_event",
  "thread": {
    "fiber_variables": {
      "ActiveRecord::ExplainRegistry": "#<ActiveRecord::ExplainRegistry:0x007f235808d0b8>",
      "ActiveRecord::RuntimeRegistry": "#<ActiveRecord::RuntimeRegistry:0x00000003b864d0>",
      "ActiveRecord::Scoping::ScopeRegistry": "#<ActiveRecord::Scoping::ScopeRegistry:0x00000006484760>",
      "ActiveSupport::Cache::Strategy::LocalCache::LocalCacheRegistry": "#<ActiveSupport::Cache::Strategy::LocalCache::LocalCacheRegistry:0x00000003b85df0>",
      "ActiveSupport::Notifications::InstrumentationRegistry": "#<ActiveSupport::Notifications::InstrumentationRegistry:0x00000003b7add8>",
      "ActiveSupport::SubscriberQueueRegistry": "#<ActiveSupport::SubscriberQueueRegistry:0x007f23580662b0>",
      "activesupport_tagged_logging_tags:40546920": [
        "a941e687-9c82-43d9-8786-be915d34d554"
      ],
      "i18n_config": "#<I18n::Config:0x0000000255c510>",
      "kaminari_rendering": false,
      "puma_server": "#<Puma::Server:0x00000003c29900>",
      "request_store": {
        "current_controller": "#<RailsAdmin::MainController:0x007f2364e051a8>",
        "current_view_context": "#<Draper::HelperProxy:0x007f2364cc97f8>"
      },
      "request_store_active": true,
      "scout_request": "#<ScoutApm::TrackedRequest:0x007f2364e0a428>"
    },
    "group": [
      "#<Thread:0x00000001a55e78 sleep_forever>",
      "#<Thread:0x00000004749f10@/app/vendor/bundle/ruby/2.4.0/gems/scout_apm-2.1.30/lib/scout_apm/agent.rb:268 sleep>",
      "#<Thread:0x00000003c29fb8@/app/vendor/bundle/ruby/2.4.0/gems/puma-3.9.1/lib/puma/plugin/tmp_restart.rb:17 sleep>",
      "#<Thread:0x00000003c1f130@puma 005@/app/vendor/bundle/ruby/2.4.0/gems/puma-3.9.1/lib/puma/thread_pool.rb:74 sleep>",
      "#<Thread:0x00000003c1e960@puma 005@/app/vendor/bundle/ruby/2.4.0/gems/puma-3.9.1/lib/puma/thread_pool.rb:74 sleep_forever>",
      "#<Thread:0x00000003c1e5a0@puma 005@/app/vendor/bundle/ruby/2.4.0/gems/puma-3.9.1/lib/puma/thread_pool.rb:74 run>",
      "#<Thread:0x00000003c1e0a0@puma 005@/app/vendor/bundle/ruby/2.4.0/gems/puma-3.9.1/lib/puma/thread_pool.rb:74 sleep>",
      "#<Thread:0x00000003c1d5b0@puma 005@/app/vendor/bundle/ruby/2.4.0/gems/puma-3.9.1/lib/puma/thread_pool.rb:74 sleep_forever>",
      "#<Thread:0x00000003c1c700@/app/vendor/bundle/ruby/2.4.0/gems/puma-3.9.1/lib/puma/reactor.rb:151 sleep>",
      "#<Thread:0x00000003c1c188@/app/vendor/bundle/ruby/2.4.0/gems/puma-3.9.1/lib/puma/thread_pool.rb:241 sleep>",
      "#<Thread:0x00000003c17890@/app/vendor/bundle/ruby/2.4.0/gems/puma-3.9.1/lib/puma/thread_pool.rb:212 sleep>",
      "#<Thread:0x00000003c16288@/app/vendor/bundle/ruby/2.4.0/gems/puma-3.9.1/lib/puma/server.rb:325 sleep>"
    ],
    "name": "puma 005",
    "priority": 0,
    "safe_level": 0,
    "self": "#<Thread:0x00000003c1e5a0@puma 005@/app/vendor/bundle/ruby/2.4.0/gems/puma-3.9.1/lib/puma/thread_pool.rb:74 run>"
  }
}
Session
Context
{
  "action": "edit",
  "component": "main",
  "environment": "production",
  "headers": {
    "HTTP_ACCEPT": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
    "HTTP_ACCEPT_ENCODING": "gzip, deflate, br",
    "HTTP_ACCEPT_LANGUAGE": "en-GB,en-US;q=0.8,en;q=0.6,de-DE;q=0.4,de;q=0.2,pt-BR;q=0.2,pt;q=0.2",
    "HTTP_AUTHORIZATION": "Basic dG9nZXRoZXItYWasdfasEZpc2MyODE4IQ==",
    "HTTP_CONNECTION": "close",
    "HTTP_CONNECT_TIME": "0",
    "HTTP_COOKIE": "_together_session_id=b9009b88e4f5123451287eb584f121f8a10",
    "HTTP_DNT": "1",
    "HTTP_HOST": "together.ch",
    "HTTP_IF_NONE_MATCH": "W/\"a2a645fd020fec7441e1082184c8b962\"",
    "HTTP_REFERER": "https://myapp.com/admin/ordinary_event/7/edit",
    "HTTP_TOTAL_ROUTE_TIME": "0",
    "HTTP_UPGRADE_INSECURE_REQUESTS": "1",
    "HTTP_USER_AGENT": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36",
    "HTTP_VERSION": "HTTP/1.1",
    "HTTP_VIA": "1.1 vegur",
    "HTTP_X_FORWARDED_FOR": "91.64.58.114",
    "HTTP_X_FORWARDED_PORT": "443",
    "HTTP_X_FORWARDED_PROTO": "https",
    "HTTP_X_REQUEST_ID": "a941e687-9c82-43d9-8786-be915d34d554",
    "HTTP_X_REQUEST_START": "1507293504176"
  },
  "hostname": "ae2a05a5-c6e2-4c4f-aca1-768bada62e7e",
  "httpMethod": "GET",
  "language": "ruby/2.4.1",
  "notifier": {
    "name": "airbrake-ruby",
    "url": "https://github.com/airbrake/airbrake-ruby",
    "version": "2.3.2"
  },
  "os": "x86_64-linux",
  "referer": "https://myapp.com/admin/ordinary_event/7/edit",
  "remoteAddr": "54.78.117.31",
  "remoteCountry": "United States",
  "remoteCountryCode": "US",
  "rootDirectory": "/app",
  "severity": "error",
  "url": "https://myapp.com/admin/ordinary_event/7/edit",
  "userAddr": "91.64.58.114",
  "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36",
  "userAgentInfo": {
    "browserName": "Chrome",
    "browserVersion": "61.0.3163.100",
    "engineName": "AppleWebKit",
    "engineVersion": "537.36",
    "isBot": false,
    "isMobile": false,
    "os": "Intel Mac OS X 10_13_0",
    "platform": "Macintosh"
  },
  "userCountry": "Germany",
  "userCountryCode": "DE",
  "version": "Rails/5.1.4"
}
dedman commented 6 years ago

@romikoops I'm seeing a similar issue too I think, intermittently @bindings is nil. Did you work out a fix?

romikoops commented 6 years ago

@dedman Hello, I have not worked on that yet. To fix that, it is required to refresh knowledge about tread safe coding, learn how Puma deals with thread and at the end to understand how to fix it in Rails admin. I expected to have some help from community who knows it better than me. Anyway, I can not wait and will start to work on that at the end of this week.

romikoops commented 6 years ago

I just moved to Thin web server and problem has gone. I will not close the issue, probably it will be fixed by somebody.

thechrisoshow commented 6 years ago

I'm seeing this issue as well using Puma. Any suggestions on how to fix this without moving to Thin?

CodeMonkeySteve commented 6 years ago

I'm having the same problem with Thin and EM-Synchrony (which uses Fibers instead of Threads, but suffers from the same RailsAdmin design problem). I hacked together a solution that monkey-patches Proxyable to use Thread/Fiber-local variables. This seems to work in my case (with RailsAdmin v0.7), and should also work in threaded environments (YMMV):

require 'rails_admin/config/proxyable'
module RailsAdmin::Config::Proxyable
  def bindings
    Thread.current[:ra_bindings] ||= {}
    Thread.current[:ra_bindings][self]
  end

  def bindings=(new_bindings)
    Thread.current[:ra_bindings] ||= {}
    Thread.current[:ra_bindings][self] = new_bindings
  end

  class Proxy
    def method_missing(name, *args, &block)
      if @object.respond_to?(name)
        reset = @object.bindings
        begin
          @object.bindings = @bindings
          response = @object.__send__(name, *args, &block)
        ensure
          @object.bindings = reset
        end
        response
      else
        super(name, *args, &block)
      end
    end
  end
end
robwise commented 5 years ago

Is anyone else having this issue? I am, and it's strange to me that such a popular gem would have this issue with Puma (which is also very popular) yet not many others are encountering this?

austinbachman commented 5 years ago

I am seeing something potentially similar on Puma as well, where the value of bindings[:object] within a nested form will sometimes evaluate to the parent model instead of the child.

Babbz75 commented 3 years ago

@mshibuya was this fix put into a released version of the gem?

mshibuya commented 3 years ago

Yes, it's there since the 2.0.0 release.