ruby-on-rails – ActionView :: Template :: Error(未定义的方
发布时间:2020-12-17 03:29:38 所属栏目:百科 来源:网络整理
导读:我对heroku有一个非常奇怪的问题.我认为看起来像这样: = 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') %t
我对heroku有一个非常奇怪的问题.我认为看起来像这样:
= 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>): 规格正在传递.在我当地一切都很好.我不知道发生了什么事. Stacktrace显示问题在于以下行: = paginate @appointments 我正在使用Rails 5.0和kaminari(1.0.0.alpha).有任何想法吗? 编辑: if ENV['RAILS_LOG_TO_STDOUT'].present? config.logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT)) end config.log_formatter = ::Logger::Formatter.new 解决方法
在Rails5中,沉默方法已从:: Logger基类中删除(参见此
issue)
因此,为了传递一个:: Logger实例,尝试传递一个公开沉默方法的ActiveSupport :: Logger实例(见documentation),如下所示: config.logger = ActiveSupport :: TaggedLogging.new(ActiveSupport :: Logger.new(STDOUT)) 注意: 我的rails控制台的一个例子(rails5和ruby2.3.??0) 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,@default_formatter=#<Logger::Formatter:0x007f890bd29fb0 @datetime_format=nil>,@formatter=#<ActiveSupport::Logger::SimpleFormatter:0x007f890bd29f10 @datetime_format=nil>,@logdev=#<Logger::LogDevice:0x007f890bd29f60 @shift_size=nil,@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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |