Rails 插件在启动时运行迁移?

编程入门 行业动态 更新时间:2024-10-27 12:24:16
本文介绍了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 插件在启动时运行迁移?

本文发布于:2023-11-05 06:23:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1560141.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:启动时   插件   Rails

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!