Permalink
Browse files

Merge pull request #1 from nodecarter/master

Table name in scoupes
  • Loading branch information...
2 parents 21adb12 + 0be03ab commit e3d4a8d53b7d820c785f25198e8544e124af1aa8 @mokevnin mokevnin committed Mar 1, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/usefull_scopes.rb
View
@@ -11,11 +11,11 @@ module UsefullScopes
}
attribute_names.each do |a|
- scope "by_#{a}", order("#{a} DESC")
- scope "asc_by_#{a}", order("#{a} ASC")
+ scope "by_#{a}", order("#{quoted_table_name}.#{a} DESC")
+ scope "asc_by_#{a}", order("#{quoted_table_name}.#{a} ASC")
scope "like_by_#{a}", lambda {|term|
quoted_term = connection.quote(term + '%')
- where("lower(#{a}) like #{quoted_term}")
+ where("lower(#{quoted_table_name}.#{a}) like #{quoted_term}")
}
end
end

0 comments on commit e3d4a8d

Please sign in to comment.