gpt4 book ai didi

ruby-on-rails - Rails 3 沙盒控制台

转载 作者:行者123 更新时间:2023-12-03 21:17:16 25 4
gpt4 key购买 nike

在 Rails 2 中,你可以运行

script/console --sandbox

这样您就可以使用生产数据而不会意外破坏任何东西。

我似乎找不到 Rails 3 的等效命令。有谁知道它是什么?

最佳答案

很简单,输入:

bundle exec rails c -s

就是这样。
$ bundle exec rails c --help
Usage: console [environment] [options]
-s, --sandbox Rollback database modifications on exit.
--debugger Enable ruby-debugging for the console.
--irb DEPRECATED: Invoke `/your/choice/of/ruby script/rails console` instead

这很简单,但有时,如果您没有运行 rails可执行使用 bundle exec ,它可能会或可能不会导致错误。为了避免这种情况, 永远 使用 bundle exec .

报价 bundler page (如果不是文档):

In some cases, running executables without bundle exec may work, if the executable happens to be installed in your system and does not pull in any gems that conflict with your bundle.

However, this is unreliable and is the source of considerable pain. Even if it looks like it works, it may not work in the future or on another machine.

关于ruby-on-rails - Rails 3 沙盒控制台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4881646/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com