Permalink
Browse files

Joins syntax updates and removal of unnecessary sanitize_sql call

  • Loading branch information...
1 parent 6f09ebb commit dacf987d5dfce6f6414477cca70ab37f87265d8b @rwdaigle committed Feb 24, 2010
@@ -27,7 +27,7 @@ class << self
# Start with an empty scope and build on it for each attr
def search(q)
[:title, :body].inject(scoped) do |combined_scope, attr|
- combined_scope.where("posts.#{attr} LIKE ?", "%#{sanitize_sql(q)}%")
+ combined_scope.where("posts.#{attr} LIKE ?", "%#{q}%")
end
end
end
@@ -6,10 +6,10 @@ class User < ActiveRecord::Base
validates_presence_of :username
scope :published, lambda {
- joins("join posts on posts.author_id = users.id").
+ joins(:posts).
where(Post.published.where_values).
group("users.id")
}
- scope :commented, joins("join comments on comments.user_id = users.id").group("users.id")
+ scope :commented, joins(:comments).group("users.id")
end

0 comments on commit dacf987

Please sign in to comment.