Heroku에서 레일스 2.3 스타일 플러그인 및 사용 중단 경고
Rails 3.2로 업그레이드하고 rake db : migrate를 실행하면 다음과 같은 형식의 오류가 발생합니다.
감가 상각 경고 : 공급 업체 / 플러그인에 Rails 2.3 스타일 플러그인이 있습니다! 이 플러그인에 대한 지원은 Rails 4.0에서 제거 될 것입니다. 그것들을 밖으로 옮기고 Gemfile에 묶거나 lib / myplugin / * 및 config / initializers / myplugin.rb로 앱에 접습니다. 이에 대한 자세한 내용은 http://weblog.rubyonrails.org/2012/01/04/rails-3-2-0-rc2-has-been-released 릴리스 노트를 참조 하십시오 . (/ app / Rakefile : 7에서 호출)
당황한 것은 내 vendor/plugins
디렉토리가 비어 있다는 것입니다. 참조하는 다른 플러그인 디렉토리가 있습니까?
Heroku를 사용하고 있습니까?
Heroku는 Rails 3.x 애플리케이션에 플러그인을 주입합니다. Rails 3에서이 주입을 피하려면 애플리케이션에 rails_12factor gem을 포함하십시오. ( Heroku Ruby 지원 2013-10-26)
rails_12factor gem은 rails 4에도 필요합니다.
이 gem이 응용 프로그램에 없으면 배포하는 동안 경고 메시지가 표시되고 자산과 로그가 작동하지 않습니다. ( Heroku 2013-10-26 레일 4 )
최근 2013-08 년까지 heroku는 항상 rails 3 앱, 권장 보석이 포함 된 앱에 플러그인을 삽입했습니다. 이것은 루비 빌드 팩의 문제였으며 2013 년 8 월 6 일에 통합 된 PR 11 로 수정되었습니다 .
당신은 시도 할 수 있습니다
::ActiveSupport::Deprecation.silenced = true
당신에 production.rb
그냥 소음 이후.
config / environment.rb에서 다음을 추가하십시오.
ActiveSupport::Deprecation.silenced = true
다음과 같이 레일을 초기화하기 전에 :
# Load the rails application
require File.expand_path('../application', __FILE__)
ActiveSupport::Deprecation.silenced = true
# Initialize the rails application
MyApp::Application.initialize!
마찬가지로 레이크 작업에서 경고를 비활성화하려면 Rakefile 상단 근처에 소음 제거 구성을 삽입하십시오.
# Load the rails application
require File.expand_path('../application', __FILE__)
ActiveSupport::Deprecation.silenced = true
# Initialize the rails application
MyApp::Application.initialize!
선택적으로 이것을 블록으로 감싸서 프로덕션 환경에서만 침묵시킬 수 있습니다.
if ENV['RAILS_ENV'] == "production"
ActiveSupport::Deprecation.silenced = true
end
내가 찾은 가장 좋은 방법은 여기 에 문서화되어 있습니다 . 이것은 당신이 검색하고 있기 때문에이 질문에 발견 가정한다 할 이전 스타일의 플러그인을 가지고 있습니다.
필자는 배포 한 앱의 특징에 따라 Capistrano 배포 중에 플러그인을 켜고 끌 수 있어야했기 때문에 모든 부분 에서 보석이 아닌 Make를 사용했습니다 . config.plugins를 사용하여 사용할 플러그인을 지정하기 전에 이 방법으로 config.before_configuration에서 "require"를 대신 사용합니다.
다음 원숭이 패치를 넣어 /lib/silence_heroku_warnings.rb
module Rails
class Plugin < Engine
alias :not_silenced_initialize :initialize
def initialize(root)
ActiveSupport::Deprecation.silence{ self.send :not_silenced_initialize, root }
end
end
end
그리고 그것을 필요 config/application.rb
단지 레일을 요구 후 :
require 'rails/all'
require File.expand_path('../../lib/silence_heroku_warnings', __FILE__)
All deprecations from 2.x-style plugins should be silenced. Other deprecations will show up.
A cleaner way than just silencing warnings, here is what you can do.
For the logger injection you can try to use Heroku's new gem that Jared Beck mentioned in his reply above.
What we did instead is this:
You can inhibit Heroku from injecting its own plugins if you have a directory by the same name in your vendor/plugins
folder. The folder just needs to exist. Heroku then will not inject its plugin, and if there is no code, Rails won't object with deprecation warnings. We just put a readme file explaining this into:
vendor/plugins/rails_log_stdout/readme.md
The purpose of Heroku's injected plugin for logging is to turn on Heroku-style logging (it requires logs to be sent to STDOUT, not to a file). To get that back, we did what I described in this answer. Tweaks to Heroku's default behaviors were needed for Unicorn anyway, so we got two birds in one stone.
The new way of silencing deprecation notices is:
config.active_support.deprecation = :silence
in your config/environments/production.rb
file.
It looks like Heroku has finally addressed this.
Injecting plugin 'rails_log_stdout'
Injecting plugin 'rails3_serve_static_assets'
Add 'rails_12factor' gem to your Gemfile to skip plugin injection
'IT story' 카테고리의 다른 글
GitHub 페이지에 Google 웹 로그 분석 추적 ID를 추가하는 방법 (0) | 2020.06.07 |
---|---|
Xcode에서 실제 iPhone 장비로 iPhone 응용 프로그램을 어떻게 배포 할 수 있습니까? (0) | 2020.06.07 |
_viewstart.cshtml 및 부분 Razor보기를 사용하는 올바른 방법은 무엇입니까? (0) | 2020.06.07 |
탄력적 검색, 여러 인덱스 대 하나의 인덱스 및 다른 데이터 세트에 대한 유형? (0) | 2020.06.07 |
주어진 숫자에 가장 가까운 합계를 가진 배열에서 세 개의 요소 찾기 (0) | 2020.06.07 |