开发者

What do we mean by this code if written in Gemfile

开发者 https://www.devze.com 2023-03-25 18:41 出处:网络
If I write the following code for example in \'Gemfile\': group :development do gem \'xyz\' end group:test do

If I write the following code for example in 'Gemfile':

group :development do
gem 'xyz'
end

group:test do
gem 'xyz'
end

What do开发者_开发百科es that mean?

Thanks.


You can specify which gems should be installed in which environment. For example, you might wanna use SQLite for development and testing, but MySQL on production. So you would write:

gem 'devise'

group :development, :test do
  gem 'sqlite'
end

group :production do
  gem 'mysql2'
end

Running bundle install --without development:test will install devise and mysql2 gems.


Only install the xyz gem in the development and test environments.

It can also be written as:

group :development, :test do
  gem 'xyz'
end


It means that all those gems in blocks will be loaded only in this environmets (test or development)

0

精彩评论

暂无评论...
验证码 换一张
取 消