Project

General

Profile

Bug #13168

Rendering of kickstart_networking_setup fails: undefined method 'each' for Safemode::Jail (ActiveRecord::AssociationRelation)

Added by Dominic Cleal over 3 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Templates
Target version:
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

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'

Related issues

Related to Foreman - Bug #13755: Allow iterating over ActiveRecord CollectionProxy in safe mode renderingClosed2016-02-17

Associated revisions

Revision ac735d74 (diff)
Added by Dominic Cleal over 3 years ago

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.

History

#1 Updated by Dominic Cleal over 3 years ago

  • Status changed from New to Assigned
  • Assignee set to Dominic Cleal

#2 Updated by The Foreman Bot over 3 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/3077 added

#3 Updated by Dominic Cleal over 3 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#4 Updated by Marek Hulán over 3 years ago

  • Related to Bug #13755: Allow iterating over ActiveRecord CollectionProxy in safe mode rendering added

Also available in: Atom PDF