Bug #16786

Don't call #to_sentence on model associations

Added by Dominic Cleal 12 months ago. Updated 12 months ago.

Assigned To:Dominic Cleal
Target version:-
Difficulty: Bugzilla link:
Found in release: Pull request:https://github.com/theforeman/foreman/pull/3912
Story points-
Velocity based estimate-
Release1.14.0Release relationshipAuto


Under Rails 5, calling #to_sentence on an association (such as SmartProxy.first.features.to_sentence) no longer works - it's only implemented on Array. It causes:

ActionView::Template::Error: undefined method `to_sentence' for #<Feature::ActiveRecord_Associations_CollectionProxy:0x00000011e105f8>
app/views/about/index.html.erb:35:in `block in app_views_about_index_html_erb_1374804635064850089_72097840'
app/views/about/index.html.erb:32:in `_app_views_about_index_html_erb__1374804635064850089_72097840'

In a few views .to_sentence is used on an association when it should first call .pluck to retrieve a specific column or call .to_s on the models, before converting to a sentence.

Associated revisions

Revision b6db72b1
Added by Dominic Cleal 12 months ago

fixes #16786 - don't call to_sentence on associations


#1 Updated by The Foreman Bot 12 months ago

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

#2 Updated by Dominic Cleal 12 months ago

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

#3 Updated by Dominic Cleal 12 months ago

  • Release set to 1.14.0

Also available in: Atom PDF