Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

render :text => Proc

#2546

As described at http://pastie.org/455603

Using render :text with a Proc causes unusual errors


class FoosController < ApplicationController
  def bar
    render :text => lambda { |response, output|
      Foo.new.inspect
      output.write "Blah"
    }
  end
end

Line 4 generates the error "Read error: #<ArgumentError: A copy of FoosController has been removed from the module tree but is still active!>". If I remove line 4, or place it outside the lambda, no error occurs and "Blah" is successfully output

Reported by Gareth Adams · April 23rd, 2009 @ 10:40 AM

State: invalid
Milestone: 3.x
Assigned to: Ryan Bigg Ryan Bigg
Importance: none

Activity

  1. Richard Fairhurst
  2. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  3. Rohit Arondekar
    Rohit Arondekar

    Tried on Rails master.

    I don't get any errors but this is what I get in the browser:

    #<Proc:0x00000004d75b78@/home/rohit/bugmash/testapp/app/controllers/foos_controller.rb:3 (lambda)>
    

    This is expected or should the output be "Blah"?

    June 23rd, 2010 @ 01:03 PM

  4. David Trasbo
    David Trasbo
    • Assigned user set to Ryan Bigg

    I followed the steps describe in the Pastie using Rails 2.3.8 and it works beautifully.

    I don't think render :text with a Proc is supposed to work in Rails 3 - it is not mentioned in the documentation. It probably simply calls to_s on whatever is passed to it and outputs that.

    This ticket can be closed. If anyone wants this behavior back they can open a separate ticket with a patch.

    June 23rd, 2010 @ 01:13 PM

  5. Ryan Bigg
    Ryan Bigg
    • State changed from new to invalid

    June 23rd, 2010 @ 01:16 PM