-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Search by several fields #86
base: master
Are you sure you want to change the base?
Conversation
|
||
def param_to_array(s) | ||
return s if s.kind_of?(Array) | ||
return [s] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant return detected.
@@ -78,6 +91,11 @@ def postgres?(model) | |||
# Figure out if this particular model uses the PostgreSQL adapter | |||
model.connection.class.to_s.match(/PostgreSQLAdapter/) | |||
end | |||
|
|||
def param_to_array(s) | |||
return s if s.kind_of?(Array) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer Object#is_a? over Object#kind_of?.
@@ -78,6 +91,11 @@ def postgres?(model) | |||
# Figure out if this particular model uses the PostgreSQL adapter | |||
model.connection.class.to_s.match(/PostgreSQLAdapter/) | |||
end | |||
|
|||
def param_to_array(s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation detected.
@@ -43,7 +52,11 @@ def get_autocomplete_select_clause(model, method, options) | |||
] + (options[:extra_data].blank? ? [] : options[:extra_data])) | |||
else | |||
table_name = model.table_name | |||
(["#{table_name}.#{model.primary_key}", "#{table_name}.#{method}"] + (options[:extra_data].blank? ? [] : options[:extra_data])) | |||
l = ["#{table_name}.#{model.primary_key}"] | |||
param_to_array(method).each do |method| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shadowing outer local variable - method.
order << active_record_get_autocomplete_order(method, options, model) | ||
end | ||
|
||
items = items.where(clauses.join(' OR '), *conditions).limit(limit).order(order.join(', ')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Line is too long. [99/80]
|
||
clauses = [] | ||
conditions = [] | ||
param_to_array(method).each do |method| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shadowing outer local variable - method.
Supports autocompletion search by several fields/methods at a time.
ActiveRecord only