2010-11-08 30 views
0

我使用jruby-1.5.3与rails 2.3.5应用程序。我刚开始使用的线程安全与玩弄:Rails 2.3.5 threadsafe!打破我的迁移

config.threadsafe! 
config.eager_load_paths << "#{RAILS_ROOT}/lib" 

的正常工作,我只注意到然而在部署到我的临时环境(具有相同配置的生产),我得到了一个未定义的常量。举例来说,这又增加了角色的角色表迁移:

class AddSuperAdminRole < ActiveRecord::Migration 
    def self.up 
    Role.create :rolename => 'super_admin' 
    end 
end 

抛出一个:

uninitialized constant AddSuperAdminRole::Role 

,因为我不是运行多线程它正常工作,在开发环境,所以我知道这就是问题。我已经尝试加载应用程序/模型路径,但没有奏效。如何使用threadsafety运行迁移?

回答

1

升级到2.3.10固定此。

+0

有没有博客文章或有关此?扫描提交我看不到修复,我真的很想看看它是否在更新版本的rails 3.谢谢! – mixonic 2010-11-30 16:08:12

+0

没有没有看到博客文章,只是搜索源...目前实际上找不到提交,但我会保持你张贴时,我做 – brad 2010-12-01 04:24:22

0

从Rails Lighthouse网站上的票#2506。下面我链接了Rails中的线程安全方法。您会看到config.dependency_loading设置为false,因为它不是线程安全的,因此迁移正在自动加载它们的依赖关系。

# Enable threaded mode. Allows concurrent requests to controller actions and 
# multiple database connections. Also disables automatic dependency loading 
# after boot, and disables reloading code on every request, as these are 
# fundamentally incompatible with thread safety. 
    def threadsafe! 
     self.preload_frameworks = true 
     self.cache_classes = true 
     self.dependency_loading = false 
     self.action_controller.allow_concurrency = true 
     self 
    end 

这里的约书亚皮克在评论中票的问题回应:

我会建议需要模型 的你在迁移的需要,或 更好,包括模型定义 再这样它的存在并不取决于 。

+0

亚我读了一些,还发现2.3.10升级后,其中包括一个修复。所以我刚升级。 – brad 2010-11-10 20:08:23