Rendering of kickstart_networking_setup fails: undefined method 'each' for Safemode::Jail (ActiveRecord::AssociationRelation)
With safemode enabled, rendering of the default kickstart_networking_setup snippet fails as some of the lookups (probably
@host.managed_interfaces or similar) are now relations rather than arrays.
2016-01-13T08:40:35 [app] [W] »There was an error rendering the Kickstart default template: « | ActionView::Template::Error: The snippet 'kickstart_networking_setup' threw an error: undefined method 'each' for Safemode::Jail (ActiveRecord::AssociationRelation) | /home/dcleal/code/foreman/foreman/lib/foreman/renderer.rb:75:in `rescue in snippet' | /home/dcleal/code/foreman/foreman/lib/foreman/renderer.rb:72:in `snippet' | /home/dcleal/.rvm/gems/ruby-2.0.0-p353@foreman/gems/safemode-1.2.2/lib/safemode/scope.rb:37:in `method_missing' | /home/dcleal/.rvm/gems/ruby-2.0.0-p353@foreman/gems/safemode-1.2.2/lib/safemode.rb:226:in `bind' | /home/dcleal/.rvm/gems/ruby-2.0.0-p353@foreman/gems/safemode-1.2.2/lib/safemode.rb:51:in `eval' | /home/dcleal/.rvm/gems/ruby-2.0.0-p353@foreman/gems/safemode-1.2.2/lib/safemode.rb:51:in `eval' | /home/dcleal/code/foreman/foreman/lib/foreman/renderer.rb:16:in `render_safe' | /home/dcleal/code/foreman/foreman/lib/foreman/renderer.rb:103:in `unattended_render'
fixes #13168 - permit safemode templates read-only access to AR relations
Templates such as kickstart_networking_setup use relations of
Host::Managed to access network interfaces. Since Rails 4, these return
relation objects rather than arrays which being core Ruby, had permitted
methods defined in safemode itself.