简体   繁体   中英

CoffeScript not working in Rails Production

I have a Rails website that works excellent in development and in test. However, in the production environment I am having issues with CoffeeScript. The following JQuery tab function is not running in production:

jQuery ->
  $("#tabs").tabs()

The above runs correctly in dev and test. It is located in the corresponding CoffeeScript file for the controller in the asset pipeline (assets/javascripts/insight.js.coffee). I have tried cleaning and then compiling my assets with:

rake assets:clean
rake assets:precompile

Here is my config file for production:

  config.cache_classes = true
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true
  config.serve_static_assets = false
  config.assets.compress = true
  config.assets.compile = true

  # Compile all files in assets folders
  files = Dir[Rails.root.join('app', 'assets', '{javascripts,stylesheets}', '**', '[^_]*.{js,css}*')]
  files.map! {|file| file.sub(%r(#{Rails.root}/app/assets/(javascripts|stylesheets)/), '') }
  files.map! {|file| file.sub(%r(\.(coffee|scss)), '') }
  config.assets.precompile += files

  config.assets.digest = true

What am I missing here?

I don't know Rails but :

assets/javascripts/insight.js.coffee

It seems that you miss a point (".") in this part of your regexp {js,css}*

 # Compile all files in assets folders
  files = Dir[Rails.root.join('app', 'assets', '{javascripts,stylesheets}', '**', '[^_]*.{js,css}.*')]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM