Actions
Bug #15975
closedsubnets/_fields partial depends on @subnet instance variable
Description
The subnets/_fields partial has a reference to the @subnet instance variable which makes it harder to reuse the partial in a nested form from a plugin (foreman_setup). Using f.object to refer to the object being rendered is more robust as it doesn't assume how the controller works.
This fixes the following error rendering the form in foreman_setup:
ActionView::Template::Error: undefined method `type' for nil:NilClass app/views/subnets/_fields.html.erb:10:in `_app_views_subnets__fields_html_erb__172584428900089411_67260780' /var/lib/workspace/workspace/test_plugin_matrix/database/sqlite3/ruby/2.3/slave/fast/plugin/app/views/foreman_setup/provisioners/_step2.html.erb:15:in `block (2 levels) in __var_lib_workspace_workspace_test_plugin_matrix_database_sqlite__ruby_____slave_fast_plugin_app_views_foreman_setup_provisioners__step__html_erb__3389724422021272400_78104880' /var/lib/workspace/workspace/test_plugin_matrix/database/sqlite3/ruby/2.3/slave/fast/plugin/app/views/foreman_setup/provisioners/_step2.html.erb:14:in `block in __var_lib_workspace_workspace_test_plugin_matrix_database_sqlite__ruby_____slave_fast_plugin_app_views_foreman_setup_provisioners__step__html_erb__3389724422021272400_78104880' app/helpers/form_helper.rb:258:in `form_for' /var/lib/workspace/workspace/test_plugin_matrix/database/sqlite3/ruby/2.3/slave/fast/plugin/app/views/foreman_setup/provisioners/_step2.html.erb:2:in `__var_lib_workspace_workspace_test_plugin_matrix_database_sqlite__ruby_____slave_fast_plugin_app_views_foreman_setup_provisioners__step__html_erb__3389724422021272400_78104880' /var/lib/workspace/workspace/test_plugin_matrix/database/sqlite3/ruby/2.3/slave/fast/plugin/app/views/foreman_setup/provisioners/step2.html.erb:3:in `__var_lib_workspace_workspace_test_plugin_matrix_database_sqlite__ruby_____slave_fast_plugin_app_views_foreman_setup_provisioners_step__html_erb__4171811634289270913_70611380' app/controllers/concerns/application_shared.rb:14:in `set_timezone' app/models/concerns/foreman/thread_session.rb:32:in `clear_thread' /var/lib/workspace/workspace/test_plugin_matrix/database/sqlite3/ruby/2.3/slave/fast/plugin/test/functional/foreman_setup/provisioners_controller_test.rb:53:in `block in <class:ProvisionersControllerTest>' (ActionView::Template::Error) /var/lib/workspace/workspace/test_plugin_matrix/database/sqlite3/ruby/2.3/slave/fast/foreman/app/views/subnets/_fields.html.erb:10
Actions