Project

General

Profile

Actions

Bug #16786

closed

Don't call #to_sentence on model associations

Added by Dominic Cleal about 8 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Rails
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

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:

AboutControllerTest#test_index:
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.

Actions

Also available in: Atom PDF