Rails 3.2.11 asset precompile fails if threadsafe! enabled

旧时模样 提交于 2020-01-05 07:00:13

问题


I'm on Rails 3.2.11 and ruby 1.9.3.125

My app is working ok in devel and production if threadsafe! off

With threadsafe! enabled I get an error during precompiling, in my asset assetsolutions.js.erb (which is the main js file of the application) I use the Workorder class as in the next line if ($('#workorder_worktype').val()=='<%= Workorder::REPAIR %>')

with threadsafe! the class can't be found at precompile time, I've done some reasearch and I think it may be related with rails switching off eager loading if threadsafe! is on

How can I include the Workorder class to make precompile work?

error follows:

c:/rails3/ruby/bin/ruby.exe c:/rails3/Ruby/bin/rake assets:precompile:all RAILS_ ENV=production RAILS_GROUPS=assets rake aborted! uninitialized constant #::Workorder (in C:/rails3/applications/assetsolutions/app/assets/javascripts/preloaded/ass etsolution.js.erb) C:/rails3/applications/assetsolutions/app/assets/javascripts/preloaded/assetsolu tion.js.erb:763:in `evaluate_source' Tasks: TOP => assets:precompile:primary (See full trace by running task with --trace) rake aborted! Command failed with status (1): [c:/rails3/ruby/bin/ruby.exe c:/rails3/Ruby...]

Tasks: TOP => assets:precompile (See full trace by running task with --trace)

Tnx Fabio


回答1:


I just had the same issue on a Rails 3.2.13 application and I solved it by adding config.eager_load = true to my config/environments/production.rb file. This also solved eager loading issues I had with rake not loading models.



来源:https://stackoverflow.com/questions/15430457/rails-3-2-11-asset-precompile-fails-if-threadsafe-enabled

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!