How to create a new environment in Ruby on Rails?

后端 未结 4 1094
伪装坚强ぢ
伪装坚强ぢ 2020-12-08 01:45

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

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

4条回答
  •  猫巷女王i
    2020-12-08 02:33

    Updated Answer for Rails 5

    Create new environment file:

    config/environments/staging.rb
    

    Modify the following files to add the environment key 'staging'

    config/cable.yml
    config/database.yml
    config/secrets.yml
    Gemfile (incase you have stage dependent gems)
    

    The new environments can now be used as usual for eg:

    rails server -e staging

    rails console staging

    Or to do conditional checks:

    rails console staging, Rails.env.staging?
    

    Good place to start for creating new environment and to modify these files is to copy production settings.

提交回复
热议问题