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

Thanks.

Only install the ‘xyz’ gem in the development and test environments.
It can also be written as

group :development, :test do
gem ‘xyz’
end

Rails has three modes: production, development, and testing. An
example: when you are developing an app, you may want to show the values
of certain variables on each page.
Looking at the values of those variables can help you understand where
any errors might be occurring. In production mode (i.e. when your
website is up and running for real) you obviously don’t
want the values of all your variables being displayed at the bottom of
your
web page. Here is some code in one of my views:

<%= debug(params) if Rails.env.development? %>

That displays the values of the params variable only when the mode is
development. In production mode, i.e. when the website is up and
running and open to the public, those variables won’t display because
the environment will be production.

Another example: for testing you might want to use a database with some
fake
info that you can alter and change with your tests–but that would mess
up the data in your real (or production) database. Rails allows you to
create a database that will be used in testing mode.

In your example, one gem is included in development mode, and another
gem is included for testing mode only. So you could infer that the gem
included for testing, is a gem that
provides facilities for writing tests.

You can freely switch between any of the modes, and often times rails
handles that automatically.

On 2 August 2011 09:44, 7stud – [email protected] wrote:

In your example, one gem is included in development mode(and presumably
production mode), and another gem is included for testing mode only. So

Only if there is a

group :production do
gem ‘xyz’
end

or the line

gem ‘xyz’

not included in a ‘group … do’ block. Otherwise presume nothing.

For further clarity Rails has three modes by convention only and you
can create as many as you like. We have ‘staging’ for our staging
environment and ‘fallback’ for the servers that will come online when
if the hosting of the main servers fails. You could also have a
‘q_and_a’ environment for the QA team to do it’s testing on.

just a detial more…
for get the gems in the gemfile you must execute “bundle install”
This way a third person don’t have to know what gems are needed for
you application, only execute bundle intall and ready