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.

current_render_extension nil after render :inline

#609

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.

Example:

<%= 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...

Reported by Daniel Guettler · July 13th, 2008 @ 04:56 AM

State: resolved
Milestone: 2.x
Assigned to: josh josh
Importance: none

Activity

  1. josh
    josh
    • State changed from new to open
    • Assigned user set to josh

    Tests plz

    July 13th, 2008 @ 05:30 AM

  2. Daniel Guettler
    Daniel Guettler
    • 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

    July 13th, 2008 @ 05:54 AM

  3. Daniel Guettler
    Daniel Guettler

    I'm not so convinced of my solution any more after coming across this related ticket: http://rails.lighthouseapp.com/p...

    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
          end
        end
    

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

    July 13th, 2008 @ 06:10 AM

  4. Repository
    Repository
    • 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 current_render_extension nil after render :inline as a side effect. [#609 state:resolved]

    http://github.com/rails/rails/co...

    July 13th, 2008 @ 07:24 PM