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.

[PATCH] More html_safe strings now use the safe_concat method

#3856

Reported by Santiago Pastorino · February 5th, 2010 @ 12:16 AM

State: committed
Milestone: none
Assigned to: Santiago Pastorino Santiago Pastorino
Importance: Low

Activity

  1. Repository
  2. korch
    korch
    • Tag changed from 3.0pre, action_view, helpers, patch, performance to 2.3-stable, 3.0pre, action_view, helpers, patch, performance
    • Assigned user changed from Yehuda Katz (wycats) to Santiago Pastorino

    I think this commit might have broken something. I'm on 2.3-stable, freshly vendor'd from github, and I'm getting this error from any template calling form_for: "undefined method safe_concat' for "":String". It's pretty easy to recreate from a tosser app, and Rails own tests currently fail for this. I am using Haml to render the bare-bones form_for inside "new.html.haml", like everybody does, and this error occurs when using either haml stable or haml-edge.

    # gem list|grep -E 'rails|haml'
    # haml (2.2.22)
    # haml-edge (2.3.184)
    # rails (2.3.5)
    
    rails foobar
    cd foobar/vendor
    git clone git://github.com/rails/rails.git
    cd rails
    git checkout -b 2-3-stable origin/2-3-stable
    
    cd actionpack
    rake test_action_pack
    

    After fifty-something FormHelper errors for "Expected block to return true value", the test output fails:

    55) Error: test_safe_concat(TextHelperTest): NoMethodError: undefined method `safe_concat' for #
        /home/korch/safe_concat_broke/vendor/rails/actionpack/lib/action_controller/test_process.rb:511:in `method_missing'
        /home/korch/safe_concat_broke/vendor/rails/actionpack/lib/action_view/test_case.rb:158:in `method_missing'
        /home/korch/safe_concat_broke/vendor/rails/actionpack/test/template/text_helper_test.rb:27:in `test_safe_concat'
        /usr/local/ruby19/lib/ruby/gems/1.9.1/gems/mocha-0.9.8/lib/mocha/integration/mini_test/version_131_and_above.rb:26:in `run'
        /home/korch/safe_concat_broke/vendor/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:24:in `run'
    

    Looking at actionpack/lib/action_view/helpers/text_helper.rb, I see it is now calling out to safe_concat. I thought this was a method only for Rails 3, so I'm not sure why it's appearing in the 2.3-stable branch(2.3.6)?

    This safe_concat helper error goes away if I change line #29 increase github commits feed length in actionpack/lib/action_view/helpers/text_helper.rb like so:

    -        output_buffer.safe_concat(string)
    +  
    output_buffer.concat(string)

    Test case attached and I think I got it right, as this is my first time submitting to Rails.

    April 2nd, 2010 @ 12:01 AM

  3. Santiago Pastorino
    Santiago Pastorino

    The test you mention aren't failing and your patch doesn't work and doesn't make your test pass.
    Can you send me another probe of a failure?.
    Thanks for helping.

    April 2nd, 2010 @ 02:23 AM