Skip to content

Commit b6e9e0e

Browse files
committed
Fix association.blank? when associated_limit=0 and includes=nil
1 parent 374ecf1 commit b6e9e0e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
= 3.5.x
44
- Load chosen on turbolinks:load event
5+
- Fix association.blank? when associated_limit=0 and includes=nil
56

67
= 3.5.1
78
- Fix set false options for date picker

lib/active_scaffold/helpers/list_column_helpers.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ def cache_association(association, column, size)
253253
# load at least one record more, is needed to display '...'
254254
association.target = association.reader.limit(column.associated_limit + 1).select(column.select_associated_columns || "#{association.klass.quoted_table_name}.*").to_a
255255
elsif @cache_associations
256-
association.target = []
256+
# set array with at least one element if size > 0, so blank? or present? works, saving [nil] may cause exceptions
257+
association.target = size.to_i.zero? ? [] : [association.klass.new]
257258
end
258259
end
259260

0 commit comments

Comments
 (0)