Skip to content

Commit

Permalink
[#996] search automatic scope should allow table names in field names
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanlarsen committed Jan 24, 2012
1 parent e4a1bee commit 8b8c691
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion hobo/lib/hobo/model/scopes/automatic_scopes.rb
Expand Up @@ -324,7 +324,10 @@ def create_scope(check_only=false)
words = query.split
args = []
word_queries = words.map do |word|
field_query = '(' + fields.map { |field| "(#{@klass.table_name}.#{field} #{match_keyword} ?)" }.join(" OR ") + ')'
field_query = '(' + fields.map { |field|
field = "#{@klass.table_name}.#{field}" unless field =~ /\./
"(#{field} #{match_keyword} ?)"
}.join(" OR ") + ')'
args += ["%#{word}%"] * fields.length
field_query
end
Expand Down

0 comments on commit 8b8c691

Please sign in to comment.