asset helpers don't work inside html in asset pipeline #5411

Closed
koenhandekyn opened this Issue Mar 13, 2012 · 3 comments

3 participants

@koenhandekyn

when using for example

<%= javascript_include_tag "application" %>

inside a .html.erb file inside the asset pipeline, this works fine at runtime but not during pre compilation due to unavailability of the "params" variable in the below method when doing asset precompilation.

  private
  def debug_assets?
    compile_assets? && (Rails.application.config.assets.debug || params[:debug_assets])
  rescue NoMethodError
    false
  end

ideally the check on the params is only performed when they are actually available (runtime configuration).

there is a fix, add this to your production.rb

module Sprockets 
module Helpers
  module RailsHelper

    private
    def debug_assets?
      false
    end

  end
end

end

@vjpr

I had this exact same issue. Changing params[:debug_assets] to params?[:debug_assets] would fix it.

@kennyj

I think that I fixed this issue and sent PR to 3-2-stable :-)
#5525

and please see also #5429.

@kennyj kennyj added a commit to kennyj/rails that referenced this issue Mar 22, 2012
@kennyj kennyj Fix GH #5411. When precompiling, params method is undefined. 8c262f7
@kennyj

I'm closing this issue, because the above PR is merged. thanks

@kennyj kennyj closed this Mar 22, 2012
@greggroth greggroth added a commit to greggroth/rails that referenced this issue Mar 26, 2012
@kennyj kennyj Fix GH #5411. When precompiling, params method is undefined. e8b51de
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment