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.

ActionView::OutputBuffer to_s should return a real String

#6288

Recently when debugging an issue rendering an email, I ran across some unexpected behavior.

To help us in our tests when rendering an email we use this:

def render(template, local_assigns={})
view = ActionView::Base.new(["features/fixtures"]) view.render :file => template, :locals => local_assigns end

We would use this rendered output to create an email, but whenever we pull parts of the email out, like the body, it returns the part as a ActionView::OutputBuffer.

Even calling to_s on the body didn't help and after looking into it, it's obvious why: ActiveSupport::SafeBuffer, which ActionView::OutputBuffer inherits, returns self when calling to_s. I would expect to_s to at least attempt to return a string, maybe something like 'String.new self'.

Is there a reason for this behavior?

For Example:

This fails:
# this is equivalent to what we get when extracting emails out of our rendered template as described in the problem above a = ActionView::OutputBuffer.new "foo@example.com" Mail:Address.new a

This succeeds:
Mail:Address.new "foo@example.com"

API Reference for ActiveSupport::SafeBuffer
http://api.rubyonrails.org/classes/ActiveSupport/SafeBuffer.html#me...

Reported by Ryan Montgomery · January 13th, 2011 @ 05:30 PM

State: stale
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. rails
    rails
    • State changed from new to open

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    April 14th, 2011 @ 01:00 AM

  2. rails
    rails
    • State changed from open to stale

    April 14th, 2011 @ 01:00 AM