Skip to content

Commit

Permalink
fix problem that caused when using 'joins'
Browse files Browse the repository at this point in the history
  • Loading branch information
nodecarter committed Mar 1, 2012
1 parent 21adb12 commit 0be03ab
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/usefull_scopes.rb
Expand Up @@ -11,11 +11,11 @@ module UsefullScopes
} }


attribute_names.each do |a| attribute_names.each do |a|
scope "by_#{a}", order("#{a} DESC") scope "by_#{a}", order("#{quoted_table_name}.#{a} DESC")
scope "asc_by_#{a}", order("#{a} ASC") scope "asc_by_#{a}", order("#{quoted_table_name}.#{a} ASC")
scope "like_by_#{a}", lambda {|term| scope "like_by_#{a}", lambda {|term|
quoted_term = connection.quote(term + '%') quoted_term = connection.quote(term + '%')
where("lower(#{a}) like #{quoted_term}") where("lower(#{quoted_table_name}.#{a}) like #{quoted_term}")
} }
end end
end end
Expand Down

0 comments on commit 0be03ab

Please sign in to comment.