Rails 3 沙盒控制台 [英] Rails 3 Sandbox Console

查看:60
本文介绍了Rails 3 沙盒控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Rails 2 中你可以运行

In Rails 2 you're able to run

script/console --sandbox

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

so you can play with production data and not accidentally break anything.

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

I can't seem to find the equivalent command for Rails 3. Does anyone know what it is?

推荐答案

简单,输入:

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

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

It is simple, but, sometimes, if you are not running rails executable using bundle exec, it may, or may not, result in an error. In order to avoid this, ALWAYS use bundle exec.

引用捆绑页面(如果不是文档):

To quote bundler page (if not documentation):

在某些情况下,运行没有 bundle exec 的可执行文件可能会起作用,如果可执行文件恰好安装在您的系统中,并且没有拉入与您的捆绑包冲突的任何宝石.

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.

这篇关于Rails 3 沙盒控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆