Forum: Ruby on Rails rawk no longer works on Rails 2.2.2

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
059ed46172a087063ce26250e44c8627?d=identicon&s=25 Fernando Perez (fernando)
on 2008-11-22 14:51
I just wanted to let you know that the hack to make rawk work on Rails
2.2.2 by grouping action calls no longer works.

This is the hack, I have put the TODO where the line crashes Rails:
--
module ActiveSupport
  class BufferedLogger
    def add(severity, message = nil, progname = nil, &block)
      return if @level > severity
      message = (message || (block && block.call) || progname).to_s
      # If a newline is necessary then create a new message ending with
a newline.
      # Ensures that the original message is not mutated.
      message = "#{message} (pid:#{$$})" if RAILS_ENV=="production"
      message = "#{message}\n" unless message[-1] == ?\n
      @buffer << message # TODO: this line no longer works with Rails
2.2.2
      auto_flush
      message
    end
  end
end
--

The error message is the following:
--
Error during failsafe response: undefined method `<<' for {}:Hash
(originally undefined method `<<' for {}:Hash)
--
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-11-22 14:57
(Received via mailing list)
On 22 Nov 2008, at 13:51, Fernando Perez wrote:

>      message = (message || (block && block.call) || progname).to_s
>      # If a newline is necessary then create a new message ending with
> a newline.
>      # Ensures that the original message is not mutated.
>      message = "#{message} (pid:#{$$})" if RAILS_ENV=="production"
>      message = "#{message}\n" unless message[-1] == ?\n
>      @buffer << message # TODO: this line no longer works with Rails

that line needs to be changed to buffer << message

Fred
059ed46172a087063ce26250e44c8627?d=identicon&s=25 Fernando Perez (fernando)
on 2008-11-22 15:31
Frederick Cheung wrote:
> On 22 Nov 2008, at 13:51, Fernando Perez wrote:
>
>>      message = (message || (block && block.call) || progname).to_s
>>      # If a newline is necessary then create a new message ending with
>> a newline.
>>      # Ensures that the original message is not mutated.
>>      message = "#{message} (pid:#{$$})" if RAILS_ENV=="production"
>>      message = "#{message}\n" unless message[-1] == ?\n
>>      @buffer << message # TODO: this line no longer works with Rails
>
> that line needs to be changed to buffer << message
>
> Fred

Smashing it works! Thanks Fred. How did you know about that? Do you
often dive into Rails source code?
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-11-22 15:46
(Received via mailing list)
On Nov 22, 2:31 pm, Fernando Perez <rails-mailing-l...@andreas-s.net>
wrote:
> Frederick Cheung wrote:

> > that line needs to be changed to buffer << message
>
> > Fred
>
> Smashing it works! Thanks Fred. How did you know about that? Do you
> often dive into Rails source code?

Well if you look at the original method this one is replacing it
seemed fairly obvious.

Fred
This topic is locked and can not be replied to.