Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

paul-at
Copy link

@paul-at paul-at commented Jun 28, 2017

Supports autocompletion search by several fields/methods at a time.

ActiveRecord only


def param_to_array(s)
return s if s.kind_of?(Array)
return [s]
Copy link
Collaborator

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)
Copy link
Collaborator

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)
Copy link
Collaborator

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|
Copy link
Collaborator

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(', '))
Copy link
Collaborator

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|
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants