This project is archived and is in readonly mode.

#609 ✓resolved
Daniel Guettler

current_render_extension nil after render :inline

Reported by Daniel Guettler | July 13th, 2008 @ 04:56 AM | in 2.x

When calling render :inline => 'Some inline content' within a template current_render_extension will become nil which will cause the CacheHelper cache method to call to_sym on nil.


<%= render :inline => "Some content inline" %>
<% cache do %>
  Cache some content here...
<% end %>

will give the following error:

You have a nil object when you didn't expect it!
The error occurred while evaluating nil.to_sym
vendor/rails/actionpack/lib/action_view/helpers/cache_helper.rb:36:in `cache'
app/views/users/index.html.erb:2:in `_run_erb_47app47views47users47index46html46erb'
vendor/rails/actionpack/lib/action_view/base.rb:342:in `send'
vendor/rails/actionpack/lib/action_view/base.rb:342:in `execute'
vendor/rails/actionpack/lib/action_view/template_handlers/compilable.rb:29:in `send'
vendor/rails/actionpack/lib/action_view/template_handlers/compilable.rb:29:in `render'
vendor/rails/actionpack/lib/action_view/template.rb:35:in `render'
vendor/rails/actionpack/lib/action_view/template.rb:22:in `render_template'
vendor/rails/actionpack/lib/action_view/base.rb:248:in `render_file'

I attached a possible patch for the cache method but I'm not sure if this shouldn't be prevented elsewhere as well...

Comments and changes to this ticket

  • josh

    josh July 13th, 2008 @ 05:30 AM

    • State changed from “new” to “open”
    • Assigned user set to “josh”

    Tests plz

  • Daniel Guettler

    Daniel Guettler July 13th, 2008 @ 05:54 AM

    • Tag changed from 2.1, actionpack, bug, helper, patch to 2.1, actionpack, bug, helper, patch, tested

    added patch with tests for render :inline followed by fragment cache

  • Daniel Guettler

    Daniel Guettler July 13th, 2008 @ 06:10 AM

    I'm not so convinced of my solution any more after coming across this related ticket:

    I'm wondering if this should not rather be changed in Template prepare! method:

        def prepare!
          @view.send :evaluate_assigns
          @view.current_render_extension = @extension
          if @handler.compilable?
            @handler.compile_template(self) # compile the given template, if necessary
            @method = @view.method_names[method_key] # Set the method name for this template and run it

    by preventing current_render_extension from being set to nil which would preserve the last active render_extension versus falling back to the default.

  • Repository

    Repository July 13th, 2008 @ 07:24 PM

    • State changed from “open” to “resolved”

    (from [e0fef66149092dd3d2988fff64f0ce8765735687]) Made ActionView::Base#first_render a little more private. And added _last_render to track the most recent render. Will fix #609 as a side effect. [#609 state:resolved]

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=""></a>

People watching this ticket

Referenced by