2016-07-13 24 views
5

私はherokuに非常に奇妙な問題があります。私はこのようなビューを持っています:ActionView :: Template :: Error(定義されていないメソッド `沈黙 ')

= content_for :header_title do 
    = t('.header_title') 

- if @appointments.exists? 
    %table.table.table-striped.table-bordered.table-hover 
    %thead 
     %tr 
     %th= t('.id') 
     %th= t('.athena_health_id') 
     %th= t('.start_time') 
     %th= t('.duration') 
     %th= t('.provider') 
     %th= t('.created_at') 
     %th= t('.updated_at') 
    %tbody 
     = render @appointments 

    = paginate @appointments 
- else 
    %h3.text-center= t('.appointments_not_found') 
%hr/ 

何も特別なものはありません。私はHerokuの上で、このテンプレートを使用しているページを訪れたとき、私は受け取る:

ActionView::Template::Error (undefined method `silence' for #<Logger:0x007f7a86267a70>): 

スペック渡しています。私の地域ではすべてがうまくいっています。私は何が起こっているのか分からない。私はRailsの5.0と雷(1.0.0.alpha)を使用してい

= paginate @appointments 

:スタックトレースは、問題がラインに従っていることを示しています。何か案は?

編集:私は私のproduction.rbで :Rails5 silence方法で

if ENV['RAILS_LOG_TO_STDOUT'].present? 
    config.logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT)) 
    end 

config.log_formatter = ::Logger::Formatter.new 
+1

誤りができないようです'Logger'と呼ばれるクラスに対して「無音」メソッドを見つけることができます。あなたのコードは 'Logger'クラスを持っていますか、それともHerokuの終わりですか? – Okomikeruko

+0

いいえ、私のクラスにはロガークラスがありません。 production.rbには、私も持っています: ENV ['RAILS_LOG_TO_STDOUT']が存在すれば? config.logger = activesupportの:: TaggedLogging.new(Logger.new(STDOUT)) 終了 config.log_formatter = ::ロガー:: Formatter.new –

+1

は、あなたが見ているか、[この](https://でgithubの。 com/rails/rails/issues/20492)githubに問題がありますか? ':: Logger'クラスの' silence'メソッドは、Rails4.2以降で廃止され、Rails5から削除されました。 – NickGnd

答えて

7

::Loggerインスタンスを渡すので、代わりに(このissueを参照)::Logger基本クラスから

を除去し、

のようにsilenceメソッドを公開するActiveSupport::Loggerインスタンスを渡そうとしてください(documentationを参照)。

注: ActiveSupport::Logger::Logger基本クラスから継承し、LoggerSilenceモジュールを含む私のrailsコンソール(rails5とruby2.3.​​0)から

例(documentationを参照)が

logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT)) 
=> #<Logger:0x007f890b8a3d10 @progname=nil, @level=0, @default_formatter=#<Logger::Formatter:0x007f890b8a2cd0 @datetime_format=nil>, @formatter=#<ActiveSupport::Logger::SimpleFormatter:0x007f890b8a26e0 @datetime_format=nil>, @logdev=#<Logger::LogDevice:0x007f890b8a2870 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<IO:<STDOUT>>, @mon_owner=nil, @mon_count=0, @mon_mutex=#<Thread::Mutex:0x007f890b8a2730>>> 
logger.silence 
NoMethodError: undefined method `silence' for #<Logger:0x007f890b8a3d10> 
# ... 

logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDOUT)) 
=> #<ActiveSupport::Logger:0x007f890bd2a028 @progname=nil, @level=0, @default_formatter=#<Logger::Formatter:0x007f890bd29fb0 @datetime_format=nil>, @formatter=#<ActiveSupport::Logger::SimpleFormatter:0x007f890bd29f10 @datetime_format=nil>, @logdev=#<Logger::LogDevice:0x007f890bd29f60 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<IO:<STDOUT>>, @mon_owner=nil, @mon_count=0, @mon_mutex=#<Thread::Mutex:0x007f890bd29f38>>, @local_levels=#<Concurrent::Map:0x007f890bd29ec0 entries=0 default_proc=nil>> 
logger.silence 
LocalJumpError: no block given (yield) 
# The method exists, but I don't pass any block 
+0

完璧な答え。 –

関連する問題