加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-17 01:20:27 所属栏目:百科 来源:网络整理
导读:在Rails 2中,您可以运行 script/console --sandbox 所以你可以玩生产数据,而不是意外地破坏任何东西. 我似乎找不到Rails 3的等效命令.有没有人知道它是什么? 解决方法 简单,输入: bundle exec rails c -s 就是这样. $bundle exec rails c --helpUsage: con
在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

这很简单,但有时,如果您不使用bundle exec运行rails可执行文件,则可能导致错误或可能导致错误.为了避免这种情况,总是使用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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读