简体   繁体   中英

Set environment to development in ruby on rails 4

How can I set my Rails environment to development?

According to this question: How do I set my rails 3 app to development mode? , you add ENV['RAILS_ENV'] = 'development' to config/environment.rb.

I did this, but when I try to bundle install, it still tries to install gems for 'production'. I've placed the environment variable line at the start, middle, and end of file.

# Load the Rails application.
require File.expand_path('../application', __FILE__)

# Initialize the Rails application.
Grafly::Application.initialize!

ENV['RAILS_ENV'] = 'development' 

This is normal. Bundler is a general-purpose dependency manager for Ruby. It has no idea that Rails exists. The group directives are exposing Bundler's groups feature , not a function of Rails.

If you don't instruct Bundler otherwise, it will install every gem from every group. It doesn't know what groups you do and don't want installed; it just knows that you defined some groups.

If you don't want to install all of your gems (or can't install all of your gems), you can skip production:

bundle install --without production

Similarly, you can skip development and testing gems when you deploy:

bundle install --without development test

(This is how, for example, Heroku and Cloud66 install only the gems you need for production.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM