本文介绍了Rails 插件在启动时运行迁移?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有插件可以让 Rails 在启动时通过 db:migrate 运行?我正在寻找一种不涉及通过 shell 调用 Rake 任务的解决方案;所以,没有system('rake db:migrate')".
Is there a plugin available to have Rails run through a db:migrate on startup? I'm looking for a solution that doesn't involve calling out to the Rake task via the shell; so, no "system('rake db:migrate')".
我可以很容易地编写自己的插件来做到这一点,但我认为如果存在的话,最好使用/改进现有的 migrate-on-init 插件.
I can readily write my own plugin to do this, but figured it would be better to use/improve an existing migrate-on-init plugin if one exists.
推荐答案这是我在 jRuby 上的 Rails 3.2 工作版本:
Here is my working version for Rails 3.2 on jRuby:
config.after_initialize do ActiveRecord::Migrator.migrate(Rails.root.join("db/migrate"), nil) end更多推荐
Rails 插件在启动时运行迁移?
发布评论