Skip to content

Commit 2bfe295

Browse files
committed
Fix #372
1 parent 1e31e31 commit 2bfe295

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/ajax-datatables-rails/orm/active_record.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def build_conditions_for_datatable
3939
crit << searchable_columns.map do |simple_column|
4040
simple_column.search = search
4141
simple_column.search_query
42-
end.reduce(:or)
42+
end.compact.reduce(:or)
4343
end.compact.reduce(:and)
4444
criteria
4545
end

spec/ajax-datatables-rails/orm/active_record_filter_records_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,20 @@
106106
expect(results).not_to include('msmith')
107107
end
108108
end
109+
110+
context 'when column.search_query returns nil' do
111+
let(:datatable) { DatatableCondUnknown.new(sample_params) }
112+
113+
before(:each) do
114+
datatable.params[:search] = { value: 'john doe', regex: 'false' }
115+
end
116+
117+
it 'does not raise error' do
118+
expect {
119+
datatable.data.size
120+
}.to_not raise_error
121+
end
122+
end
109123
end
110124
end
111125

0 commit comments

Comments
 (0)