2015-01-09 4 views
4

시나 프로젝트가 경고 인상 경고시나 트랜잭션 콜백에서 :액티브 액티브 보석과 ​​

DEPRECATION WARNING: Currently, Active Record suppresses errors raised 
within `after_rollback`/`after_commit` callbacks and only print them 
to the logs. In the next version, these errors will no longer be 
suppressed. Instead, the errors will propagate normally just like in 
other Active Record callbacks. 

You can opt into the new behavior and remove this warning by setting: 


**config.active_record.raise_in_transactional_callbacks = true** 

이 Gemfile.lock이

activemodel (4.2.0) 

     activesupport (= 4.2.0) 
     builder (~> 3.1) 

어떻게 제거 할 수 있습니까? 감사!

편집 : 미니 프로젝트는 오류 메시지가 무엇을 알려줍니다 여기 https://gist.github.com/williamhqs/c127e5d7018aa61cb02a

+0

문제를 드러내는 최소한의 Gemfile + sinatra 앱을 게시 할 수 있습니까? 나는 그것을 여기서 재현 할 수 없다. 이것은 내가 시도한 것이다. https://gist.github.com/padde/560c81db91b591ae2d84 –

+0

안녕하세요 @PatrickOscity 문제는 after_commit를 호출 한 후에 발생했습니다. 다음은 샘플 프로젝트입니다. https://gist.github.com/williamhqs/c127e5d7018aa61cb02a –

+0

@PatrickOscity 그냥 요점 클래스 인 Student

답변

4

입니다. 레일에서 당분간 응용 프로그램이 줄을 추가 :

config.active_record.raise_in_transactional_callbacks = true 

이시나에서, 당신은 ActiveRecord::Base에 직접 작업을 수행 할 수 있습니다

ActiveRecord::Base.raise_in_transactional_callbacks = true 

이 구성 옵션 자체가 더 이상 사용되지 않습니다 것을 명심하십시오 Active Record의 다음 릴리스와 함께

+0

이것을 configure 블록에 추가 하시겠습니까? –

+0

@ E.E.33 Rails 또는 Sinatra? –

+0

Sinatra please. –

1

패트릭 경고를 제거하고 새 동작에 갈 오른쪽, 당신은

레일을 추가해야합니다 :config.active_record.raise_in_transactional_callbacks = true

시나를 : ActiveRecord::Base.raise_in_transactional_callbacks = true

내가 약간의 배경에 대한 생각 정확하게 무엇을하는 것이 중요합니다. https://github.com/rails/rails/pull/16537https://github.com/rails/rails/pull/14488

after_commit/after_rollback의 실제 동작 : 오류가있는 경우 오류는 기록되지만 로그되지는 않습니다. 오류가 현재 실행을 중지하지 않는다는 것을 의미합니다.

after_commit/after_rollback에 대한 Futur Behavior : 오류가 발생하면 오류가 기록되고 화면이 흐려지지 않습니다. 오류가 현재 실행을 중지 함을 의미합니다.

표시되는 경고는 미래의 동작을 사용자에게 알리기위한 것이며이 경고는 이후 버전의 Rails/ActiveRecord에서 제거됩니다.