This project is archived and is in readonly mode.
ActionView::OutputBuffer to_s should return a real String
Reported by Ryan Montgomery | January 13th, 2011 @ 05:30 PM
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...
Comments and changes to this ticket
-
rails April 14th, 2011 @ 01:00 AM
- 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.
-
rails April 14th, 2011 @ 01:00 AM
- State changed from open to stale
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>