Skip to content

Commit 23bd97c

Browse files
authored
Avoid Rails deprecation warning
DEPRECATION WARNING: Dangerous query method (method whose arguments are used as raw SQL) called with non-attribute argument(s): "LOWER(school_districts.name) ASC". Non-attribute arguments will be disallowed in Rails 6.0. This method should not be called with user-provided values, such as request parameters or model attributes. Known-safe values can be passed by wrapping them in Arel.sql(). (called from preprocess_order_args at /Users/shanecav/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.0/lib/active_record/relation/query_methods.rb:1129)
1 parent 4b54ddf commit 23bd97c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/rails-jquery-autocomplete/orm/active_record.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ def active_record_get_autocomplete_order(method, options, model=nil)
55
order = options[:order]
66

77
table_prefix = model ? "#{model.table_name}." : ""
8-
if sqlite?
8+
sql = if sqlite?
99
order || "LOWER(#{method}) ASC"
1010
else
1111
order || "LOWER(#{table_prefix}#{method}) ASC"
1212
end
13+
14+
Arel.sql(sql)
1315
end
1416

1517
def active_record_get_autocomplete_items(parameters)

0 commit comments

Comments
 (0)