optimization: prefer relation.none over relation.where("false")

Using `relation.none` instead of `relation.where("false")` avoids an sql query.
This commit is contained in:
evazion
2018-08-23 15:21:51 -05:00
parent db23e06a4f
commit 85ae2cda0d
4 changed files with 5 additions and 5 deletions

View File

@@ -64,7 +64,7 @@ class Comment < ApplicationRecord
end
def for_creator(user_id)
user_id.present? ? where("creator_id = ?", user_id) : where("false")
user_id.present? ? where("creator_id = ?", user_id) : none
end
def for_creator_name(user_name)