Commit 5e1286bd by vulehuan

update .exists syntax when using mongoid

parent 178070c3
...@@ -4,7 +4,7 @@ class SessionsController < ApplicationController ...@@ -4,7 +4,7 @@ class SessionsController < ApplicationController
end end
def create def create
user = User.find_by(email: params[:session][:email].downcase) user = User.find_by(email: params[:session][:email].downcase) if User.where(email: params[:session][:email].downcase).exists?
if user && user.authenticate(params[:session][:password]) if user && user.authenticate(params[:session][:password])
sign_in user sign_in user
redirect_back_or user redirect_back_or user
......
...@@ -13,7 +13,7 @@ class UsersController < ApplicationController ...@@ -13,7 +13,7 @@ class UsersController < ApplicationController
end end
def show def show
if User.exists?(params[:id]) if User.where(id: params[:id]).exists?
@user = User.find(params[:id]) @user = User.find(params[:id])
else else
flash[:error] = "Invalid user!" flash[:error] = "Invalid user!"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment