如何在 Ruby on Rails 中创建新环境? [英] How to create a new environment in Ruby on Rails?

查看:73
本文介绍了如何在 Ruby on Rails 中创建新环境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个新环境(构建),以便与 hudson 一起使用.

I'm trying to create a new environment (build) for using it with hudson.

我这样做是因为我不想将我的测试数据库与 hudson 测试数据库混淆.

I'm doing this because I didn't want to mix up my test databases with hudson test database.

推荐答案

假设您要创建 hudson 环境.

Assuming you want create the hudson environment.

  1. config/environments/hudson.rb 中创建一个新的环境文件.您可以先克隆一个现有的,例如 config/environments/test.rb.
  2. config/database.yml 中为您的环境添加一个新的配置块.
  3. 使用新环境更新 config 文件夹下的任何其他配置文件,一些 gem 在 config 下创建自己的 ymls文件夹.
  4. 仅此而已.
  1. Create a new environment file in config/environments/hudson.rb. You can start by cloning an existing one, for instance config/environments/test.rb.
  2. Add a new configuration block in config/database.yml for your environment.
  3. Update any other configuration file you might have under the config folder with your new environment, some gems create their own ymls under the config folder.
  4. That's all.

现在可以启动服务器了

rails server -e hudson

或者运行控制台

rails console hudson

等等.

如果您使用的是旧版 Rails,则命令为

If you are using an older version of Rails, the commands are

ruby script/server -e hudson
ruby script/console hudson

这篇关于如何在 Ruby on Rails 中创建新环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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