Simplicity
Simplicity

Reputation: 48916

What do we mean by this code if written in Gemfile

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

group :development do
gem 'xyz'
end

group:test do
gem 'xyz'
end

What does that mean?

Thanks.

Upvotes: 0

Views: 62

Answers (3)

NARKOZ
NARKOZ

Reputation: 27911

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

It can also be written as:

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

Upvotes: 3

fl00r
fl00r

Reputation: 83680

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

Upvotes: 2

bassneck
bassneck

Reputation: 4043

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.

Upvotes: 5

Related Questions