Skip to content

Loading…

Undefined method `perform_caching' for {}:Hash, rails 3.1.0.rc4, sprockets #1992

Closed
tstramer opened this Issue · 1 comment

2 participants

@tstramer

Background: Trying to compile a HAML template in a javascript file using the new asset pipeline.

Setup

  • WEBBrick server
  • Running locally on Mac OS X Snow Leapord

Code:

app/assets/javascripts/templates.js.coffee.erb:

<% av = ApplicationController.view_context_class.new %>
<% tmpl = av.render :file => "#{Rails.root}/app/views/shared/_templates.html.haml" %>

app/views/shared/_templates.html.haml:

%script{:id => "xxxxxxxx", :type => "text/html"}
%span.spinner{:id => "${name}"}
= image_tag "spinner.gif", :size => "${size}"

Error:

The error is getting triggered on the image_tag line in _templates.html.haml.

ActionView::Template::Error (undefined method perform_caching' for {}:Hash
(in xxxxxxxx/app/assets/javascripts/templates.js.coffee.erb)):
24: %script{:id => "xxxxxxxx", :type => "text/html"}
25: %span.spinner{:id => "${name}"}
26: = image_tag "spinner.gif", :size => "${size}"
app/views/shared/_templates.html.haml:26:in
_app_views_shared__templates_html_haml___1937702501_2191138060'
app/assets/javascripts/templates.js.coffee.erb:2:in evaluate_source'
app/views/layouts/application.html.haml:17:in
_app_views_layouts_application_html_haml___1515001271_2192942720'

Digging deeper, the actual error occurs in "/Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/sprockets/helpers/rails_helper.rb" on line 109. The code is:

@config ? @config.perform_caching : Rails.application.config.action_controller.perform_caching

Note that I added a 'debugger' line right before the line above. Also, that line seems to be getting triggered several times successfully when ruby-debug gives me:

(rdb:4) p @config
#<OrderedHash {}>

but fails on:

(rdb:4) p @config
{}

Backtrace:

--> #0 Sprockets::Helpers::RailsHelper::AssetPaths.performing_caching?
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/sprockets/helpers/rails_helper.rb:109
#1 Sprockets::Helpers::RailsHelper::AssetPaths.rewrite_asset_path(source#String,...)
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/sprockets/helpers/rails_helper.rb:90
#2 ActionView::Helpers::AssetPaths.compute_public_path(source#String, dir#String,...)
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/action_view/helpers/asset_paths.rb:23
#3 Sprockets::Helpers::RailsHelper::AssetPaths.compute_public_path(source#String,...)
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/sprockets/helpers/rails_helper.rb:76
#4 ActionView::Helpers::AssetTagHelper.path_to_image(source#String)
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/action_view/helpers/asset_tag_helper.rb:277
#5 ActionView::Helpers::AssetTagHelper.image_tag(source#String, options#Hash)
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/action_view/helpers/asset_tag_helper.rb:347
#6 ActionView::CompiledTemplates._app_views_shared__templates_html_haml___1937702501_2191138060(local_assigns#Hash,...)
at line /Users/tstramer/Dropbox/csng/coursedrawer/site/app/views/shared/_templates.html.haml:26
#7 Kernel.send(view##Class:0x105361ab8, locals#Hash, buffer#NilClass)
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/action_view/template.rb:144
#8 ActiveSupport::Notifications.render(name#String, payload#Hash)
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/action_view/template.rb:144
#9 ActionView::Template.render(view##Class:0x105361ab8, locals#Hash, buffer#NilClass,...)
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/action_view/template.rb:142
#10 ActiveSupport::Notifications::Instrumenter.render_template(name#String, payload#Hash,...)
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/action_view/renderer/template_renderer.rb:40
#11 ActiveSupport::Notifications.instrument(name#String, payload#Hash)
at line /Library/Ruby/Gems/1.8/gems/activesupport-3.1.0.rc4/lib/active_support/notifications.rb:55
#12 ActionView::AbstractRenderer.to_s(name#Symbol, options#Hash)
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/action_view/renderer/abstract_renderer.rb:33
#13 ActionView::TemplateRenderer.render_template(path#NilClass, locals#Hash)
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/action_view/renderer/template_renderer.rb:39
#14 ActionView::TemplateRenderer.render_template(template#ActionView::Template, layout_name#NilClass,...)
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/action_view/renderer/template_renderer.rb:38
#15 ActionView::AbstractRenderer.default(value#String)
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/action_view/renderer/template_renderer.rb:12
#16 ActionView::TemplateRenderer.
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/action_view/renderer/template_renderer.rb:9
#17 ActionView::Renderer.render_template(context##Class:0x105361ab8, options#Hash,...)
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/action_view/renderer/renderer.rb:36
#18 ActionView::Renderer.render(context##Class:0x105361ab8, options#Hash)
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/action_view/renderer/renderer.rb:17
#19 ActionView::Helpers::RenderingHelper.render_without_haml(options#Hash, locals#Hash,...)
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/action_view/helpers/rendering_helper.rb:24
#20 ActionView::Base.render
at line /Library/Ruby/Gems/1.8/gems/haml-3.1.2/lib/haml/helpers/action_view_mods.rb:13
#21 Kernel.evaluate_source(scope##Class:0x105400578, locals#Hash, block#NilClass,...)
at line /Users/tstramer/Dropbox/csng/coursedrawer/site/app/assets/javascripts/templates.js.coffee.erb:2
#22 Tilt::Template.-(scope##Class:0x105400578, locals#Hash)
at line /Library/Ruby/Gems/1.8/gems/tilt-1.3.2/lib/tilt/template.rb:209
#23 Tilt::Template.cached_evaluate(scope##Class:0x105400578, locals#Hash)
at line /Library/Ruby/Gems/1.8/gems/tilt-1.3.2/lib/tilt/template.rb:144
#24 Tilt::Template.evaluate(scope##Class:0x105400578, locals#Hash)
at line /Library/Ruby/Gems/1.8/gems/tilt-1.3.2/lib/tilt/template.rb:127
#25 Tilt::Template.render(scope##Class:0x105400578, locals#Hash)
at line /Library/Ruby/Gems/1.8/gems/tilt-1.3.2/lib/tilt/template.rb:76
#26 Array.evaluate
at line /Library/Ruby/Gems/1.8/gems/sprockets-2.0.0.beta.10/lib/sprockets/context.rb:107
#27 Sprockets::Context.evaluate(filename#Pathname, options#Hash)
at line /Library/Ruby/Gems/1.8/gems/sprockets-2.0.0.beta.10/lib/sprockets/context.rb:104
#28 Sprockets::BundledAsset.initialize(environment#Sprockets::Environmen..., logical_path#String,...)
at line /Library/Ruby/Gems/1.8/gems/sprockets-2.0.0.beta.10/lib/sprockets/bundled_asset.rb:22
#29 Sprockets::EnvironmentIndex.new(logical_path#String, pathname#Pathname, options#Hash,...)
at line /Library/Ruby/Gems/1.8/gems/sprockets-2.0.0.beta.10/lib/sprockets/environment_index.rb:118
#30 Sprockets::EnvironmentIndex.find_asset(path#Pathname, options#Hash)
at line /Library/Ruby/Gems/1.8/gems/sprockets-2.0.0.beta.10/lib/sprockets/environment_index.rb:64
#31 Sprockets::Environment.initialize_copy(logical_path#Pathname, options#Hash)
at line /Library/Ruby/Gems/1.8/gems/sprockets-2.0.0.beta.10/lib/sprockets/environment.rb:89
#32 Array.compute_dependencies!
at line /Library/Ruby/Gems/1.8/gems/sprockets-2.0.0.beta.10/lib/sprockets/bundled_asset.rb:96
#33 Sprockets::BundledAsset.compute_dependencies!(index#Sprockets::Environment, requires#Array,...)
at line /Library/Ruby/Gems/1.8/gems/sprockets-2.0.0.beta.10/lib/sprockets/bundled_asset.rb:92
#34 Sprockets::BundledAsset.initialize(environment#Sprockets::Environmen..., logical_path#Pathname,...)
at line /Library/Ruby/Gems/1.8/gems/sprockets-2.0.0.beta.10/lib/sprockets/bundled_asset.rb:31
#35 Sprockets::EnvironmentIndex.new(logical_path#Pathname, pathname#Pathname, options#Hash,...)
at line /Library/Ruby/Gems/1.8/gems/sprockets-2.0.0.beta.10/lib/sprockets/environment_index.rb:118
#36 Sprockets::EnvironmentIndex.find_asset_in_path(logical_path#Pathname, options#Hash,...)
at line /Library/Ruby/Gems/1.8/gems/sprockets-2.0.0.beta.10/lib/sprockets/environment_index.rb:100
#37 Sprockets::EnvironmentIndex.find_asset(path#Pathname, options#Hash)
at line /Library/Ruby/Gems/1.8/gems/sprockets-2.0.0.beta.10/lib/sprockets/environment_index.rb:71
#38 Sprockets::Environment.initialize_copy(logical_path#Pathname, options#Hash)
at line /Library/Ruby/Gems/1.8/gems/sprockets-2.0.0.beta.10/lib/sprockets/environment.rb:89
#39 Sprockets::Helpers::RailsHelper::AssetPaths.asset_for(source#String, ext#String,...)
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/sprockets/helpers/rails_helper.rb:83
#40 Array.javascript_include_tag
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/sprockets/helpers/rails_helper.rb:24
#41 Sprockets::Helpers::RailsHelper.javascript_include_tag
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/sprockets/helpers/rails_helper.rb:23
#42 ActionView::CompiledTemplates._app_views_layouts_application_html_haml___1515001271_2192942720(local_assigns#Hash,...)
at line /Users/tstramer/Dropbox/csng/coursedrawer/site/app/views/layouts/application.html.haml:17
#43 Kernel.send(view##Class:0x1056acdf8, locals#Hash, buffer#NilClass)
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/action_view/template.rb:144
#44 ActiveSupport::Notifications.render(name#String, payload#Hash)
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/action_view/template.rb:144
#45 ActionView::Template.render(view##Class:0x1056acdf8, locals#Hash, buffer#NilClass,...)
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/action_view/template.rb:142
#46 ActionView::TemplateRenderer.render_with_layout(path#String, locals#Hash)
at line /Library/Ruby/Gems/1.8/gems/actionpack-3.1.0.rc4/lib/action_view/renderer/template_renderer.rb:52

@spastorino spastorino closed this in 2aefff8
@spastorino
Ruby on Rails member

@tstramer can you please check against 3-1-stable now?. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.