如果线程安全,Rails 3.2.11资产预编译将失败!已启用 [英] Rails 3.2.11 asset precompile fails if threadsafe! enabled
问题描述
我正在使用Rails 3.2.11和ruby 1.9.3.125
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
使用线程安全!启用我在资产中的预编译过程中出现错误 assetsolutions.js.erb(这是应用程序的主要js文件),我使用 工单类如下一行 如果($('#workorder_worktype').val()=='<%= Workorder :: REPAIR%>')
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 %>')
使用线程安全!在预编译时找不到该类,我做了一些研究,我认为如果线程安全,它可能与Rails关闭急切的加载有关!已开启
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
如何包含Workorder类以进行预编译工作?
How can I include the Workorder class to make precompile work?
错误如下:
c:/rails3/ruby/bin/ruby.exe c:/rails3/Ruby/bin/rake资产:预编译:所有RAILS_ ENV =生产RAILS_GROUPS =资产 耙子流产了! 未初始化的常量#:: Workorder (在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:在`evaluate_source'中 任务:TOP => asset:precompile:primary (通过使用--trace运行任务来查看完整的跟踪) 耙子流产了! 命令失败,状态为(1):[c:/rails3/ruby/bin/ruby.exe c:/rails3/Ruby ...]
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...]
任务:TOP =>资产:预编译 (通过使用--trace运行任务,查看完整的跟踪信息)
Tasks: TOP => assets:precompile (See full trace by running task with --trace)
Tnx 法比奥
推荐答案
我在Rails 3.2.13应用程序上遇到了同样的问题,我通过在config/environments/production.rb
文件中添加config.eager_load = true
来解决了这个问题.这也解决了我在rake无法加载模型时遇到的迫切加载问题.
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.
这篇关于如果线程安全,Rails 3.2.11资产预编译将失败!已启用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!