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.
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...
Comments and changes to this ticket
-
Joshua Peek July 13th, 2008 @ 05:30 AM
- → State changed from new to open
- → Assigned user changed from to Joshua Peek
Tests plz
-

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 July 13th, 2008 @ 06:10 AM
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 endby preventing current_render_extension from being set to nil which would preserve the last active render_extension versus falling back to the default.
-

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]
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Source available from github
Repository is at http://github.com/rails/rails
Check out the development master (Edge Rails):
git clone git://github.com/rails/rails.git
Creating or reviewing a patch
See the contributor guide.
Creating a feature request
Please don't. If you want a new feature in Rails, you'll have to pull up your sleeves and get busy yourself. Or convince someone else to do it. See the contributor guide on how to get going. But posting them here is just going to lead to ticket root.
Creating a bug report
When creating a bug report, be sure to include as much relevant information as possible. Post the code sample that causes the problem. Preferably, alter the unit tests and show through either changed or added tests how the expected behavior is not occuring.
Security vulnerabilities should be reported via an email to security@rubyonrails.org, do not use trac for reporting security vulnerabilities. All content in trac is publicly available as soon as it is posted.
Then don't get your hopes up. Unless you have a "Code Red, Mission Critical, The World is Coming to an End" kinda bug, you're creating this ticket in the hope that others with the same problem will be able to collaborate with you on solving it. Do not expect that the ticket automatically will see any activity or that others will jump to fix it. Creating a ticket like this is mostly to help yourself start on the path of fixing the problem and for others to sign on to with a "I'm having this problem too"..
