У меня есть приложение, развернутое на heroku, которое использует postgres. Приложение не стабильно ... иногда работает и иногда выдает пользовательскую ошибку на 500 страниц.
Код, на котором выдается ошибка:
def login
session[:user_id] = nil
if request.post?
if @user = User.authenticate(params[:user][:userid], params[:user][:password])
session[:user_id] = @user.id
if @user.stores.length > 0
redirect_to(:controller => "admin", :action => "select_store")
else
redirect_to(:controller => "pages", :action => "mainpage")
end
else
flash.now[:notice] = "Invalid user/password combination"
end
end
end
моя модель выглядит так:
def self.authenticate(userid, password)
user = self.find_by_userid_and_password(userid, password)
user
end
Герои бревен говорят:
ActiveRecord::StatementInvalid (PGError: ERROR: current transaction is aborted, commands ignored until end of transaction block
: SELECT * FROM "users" WHERE ("users"."userid" = E'sampleuser' AND "users"."password" = E'12345') LIMIT 1):
app/models/user.rb:7:in `authenticate'
app/controllers/admin_controller.rb:6:in `login'
, поскольку это временная ошибка, я не знаю, как ее исправить. Но возможно ли показать ошибки на странице? .... Можно ли перехватывать подобные ошибки, а затем продолжать? что было бы лучшим решением