Skip to content

Commit

Permalink
Fix association.blank? when associated_limit=0 and includes=nil
Browse files Browse the repository at this point in the history
  • Loading branch information
scambra committed Jun 21, 2018
1 parent 374ecf1 commit b6e9e0e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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

= 3.5.1
- Fix set false options for date picker
Expand Down
3 changes: 2 additions & 1 deletion lib/active_scaffold/helpers/list_column_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ def cache_association(association, column, size)
# load at least one record more, is needed to display '...'
association.target = association.reader.limit(column.associated_limit + 1).select(column.select_associated_columns || "#{association.klass.quoted_table_name}.*").to_a
elsif @cache_associations
association.target = []
# set array with at least one element if size > 0, so blank? or present? works, saving [nil] may cause exceptions
association.target = size.to_i.zero? ? [] : [association.klass.new]
end
end

Expand Down

0 comments on commit b6e9e0e

Please sign in to comment.