OSDN Git Service

Fix User#by_username_or_id for postgres
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Tue, 10 Dec 2013 11:20:35 +0000 (13:20 +0200)
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Tue, 10 Dec 2013 11:20:35 +0000 (13:20 +0200)
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
app/models/user.rb

index 3080851..f1f68d5 100644 (file)
@@ -198,7 +198,7 @@ class User < ActiveRecord::Base
     end
 
     def by_username_or_id(name_or_id)
-      where('username = ? OR id = ?', name_or_id, name_or_id).first
+      where('users.username = ? OR users.id = ?', name_or_id, name_or_id.to_i).first
     end
 
     def build_user(attrs = {}, options= {})