- 
                Notifications
    You must be signed in to change notification settings 
- Fork 68
Open
Description
I'm working on the log in with sessions_controller, so my create function looks like this:
def create
    user_password = params[:session][:password]
    user_email = params[:session][:email]
    user = user_email.present? && User.find_by(email: user_email)
    if user and user.valid_password? user_password
      sign_in user, store: false
      user.generate_authentication_token!
      user.save
      render json: user, status: 200, location: [:api, user]
    else
      render json: { errors: "Invalid email or password" }, status: 422
    end
  endSo when the user does not exist, I got a 500 error instead of a 422. Any ideas? I tried rescue ActiveRecord::RecordNotFound   but it's not working for me.
Metadata
Metadata
Assignees
Labels
No labels