I get this page when incorrect form login details are entered:
When credentials are correct the user is just logged in. When they're invalid this error page comes up. How do I catch this page and handle the error myself? E.G. redirect to same page or add the error to my array of errors rather than have this page show up?
Controller:
class UserController < ApplicationController
def index
end
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.valid?
user = Parse::User.authenticate(params[:user][:username], params[:user][:password])
login user
#login_permanent user if params[:session][:remember_me] == "1"
redirect_to '/adminpanel/show'
else
flash.now[:error] = "Invalid email password combination"
render 'new'
end
end
end
You can wrap the line that's producing the error in a
begin ... rescue
block:You can also catch unhandled exceptions/errors by using
rescue_from
in yourApplicationController
.