Clayton Selby
Clayton Selby

Reputation: 1254

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?

Upvotes: 0

Views: 109

Answers (1)

isThisLove
isThisLove

Reputation: 269

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}.*')]

Upvotes: 0

Related Questions