File tree Expand file tree Collapse file tree 4 files changed +9
-9
lines changed
lib/ajax-datatables-rails/datatable
ajax-datatables-rails/datatable Expand file tree Collapse file tree 4 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -212,15 +212,15 @@ end
212
212
213
213
See [ here] ( #columns-syntax ) to get more details about columns definitions and how to play with associated models.
214
214
215
- You can customize or sanitize the search value passed to the DB by using the ` :formater ` option :
215
+ You can customize or sanitize the search value passed to the DB by using the ` :formatter ` option :
216
216
217
217
``` ruby
218
218
def view_columns
219
219
@view_columns ||= {
220
220
id: { source: " User.id" },
221
221
first_name: { source: " User.first_name" },
222
222
last_name: { source: " User.last_name" },
223
- email: { source: " User.email" , formater : -> (o) { o.upcase } },
223
+ email: { source: " User.email" , formatter : -> (o) { o.upcase } },
224
224
bio: { source: " User.bio" },
225
225
}
226
226
end
Original file line number Diff line number Diff line change @@ -52,14 +52,14 @@ def custom_field?
52
52
!source . include? ( '.' )
53
53
end
54
54
55
- # Add formater option to allow modification of the value
55
+ # Add formatter option to allow modification of the value
56
56
# before passing it to the database
57
- def formater
58
- @view_column [ :formater ]
57
+ def formatter
58
+ @view_column [ :formatter ]
59
59
end
60
60
61
61
def formated_value
62
- formater ? formater . call ( search . value ) : search . value
62
+ formatter ? formatter . call ( search . value ) : search . value
63
63
end
64
64
65
65
private
Original file line number Diff line number Diff line change 128
128
end
129
129
end
130
130
131
- describe '#formater ' do
131
+ describe '#formatter ' do
132
132
let ( :datatable ) { DatatableWithFormater . new ( view ) }
133
133
let ( :column ) { datatable . datatable . columns . find { |c | c . data == 'last_name' } }
134
134
135
135
it 'should be a proc' do
136
- expect ( column . formater ) . to be_a ( Proc )
136
+ expect ( column . formatter ) . to be_a ( Proc )
137
137
end
138
138
end
139
139
Original file line number Diff line number Diff line change @@ -18,6 +18,6 @@ def view_columns
18
18
19
19
class DatatableWithFormater < ComplexDatatable
20
20
def view_columns
21
- super . deep_merge ( last_name : { formater : -> ( o ) { o . upcase } } )
21
+ super . deep_merge ( last_name : { formatter : -> ( o ) { o . upcase } } )
22
22
end
23
23
end
You can’t perform that action at this time.
0 commit comments