2010-01-24 6 views
1

heroku에서 실행되는 작은 무료 앱이 있습니다.heroku 현재 거래가 중단되었습니다.

간헐적으로 앱이 작동을 멈추고 화면에 기본 영웅 오류 페이지가 표시됩니다. 난 그냥 다음을 수행하고 내 컨트롤러에서

ActiveRecord::StatementInvalid (PGError: ERROR: current transaction is aborted, commands ignored until end of transaction block : SELECT * FROM "users" WHERE ("users"."password" = E'' AND "users"."userid" = E'') LIMIT 1): app/models/user.rb:5:in authenticate'
app/controllers/admin_controller.rb:6:in
login'

을 :

user = User.authenticate(params[:storeid], params[:password]) 

및 사용자 모델에서

가 :

def self.authenticate(userid, password) 
    user = self.find_by_userid_and_password(userid, password) 
    user 
    end 

오류 메시지가 날 리드 내가 로그를 확인할 때 나는 다음을 참조 어떤 연결은 교수형에 처해 있고 결코 닫히지 않는다고 생각하는 것. 루비 앱에서 이런 경우가 있습니까?

내 응용 프로그램에는 find_by_sql을 사용하는 곳이 많이 있습니다. 우리가 명시 적으로 연결을 끊어야합니까? 이처럼

는 :

@sqlstmmt1 = "INSERT INTO addresses (\"line1\", \"line2\", city, state, zip, county) VALUES ('" + params[:line1] + "', '"+ params[:line2] + "', '"+params[:city]+ "', '" + params[:state] + "', '" + params[:zip]+ "', '" + params[:county]+"')" 
sql = ActiveRecord::Base.connection(); 
sql.begin_db_transaction 

답변

0

나는 때문에 내가 UTF-8 문자를 삽입 할 때 무슨 생각으로 그 오류가 발생, 그래서 암호가 이국적인 문자가있을 것 같아요. BTW : 사용하는 SQL 문자열을 이스케이프해야하며, params [: anything]를 포함시키는 것은 baaaad입니다.

내가 비슷한 오류 및 레일 문서의이 비트를 얻고 있었다
0

은 도움이 : 난 그냥 응용 프로그램과 모든 재발

0

http://apidock.com/rails/ActiveRecord/Transactions/ClassMethods

Warning: one should not catch ActiveRecord::StatementInvalid exceptions inside a transaction block. ActiveRecord::StatementInvalid exceptions indicate that an error occurred at the database level, for example when a unique constraint is violated. On some database systems, such as PostgreSQL, database errors inside a transaction cause the entire transaction to become unusable until it’s restarted from the beginning. Here is an example which demonstrates the problem:

는 ... 백 우측

간다
heroku restart 

희망이 도움이 될 것입니다!

관련 문제