Reputation: 18308
I got confused of some Rails' concepts like: gemset, rubygems, bundler . I have following three questions:
1. After I installed the RVM tool, what are the correct steps to setup the development enviroment for creating a rails project (say rails v2.3 project)
2. What is the difference between "gem install XXX
" and "bundle install
"? Can I understand it in the way that "bundle install
" install all gems needed in the app at once while "gem install XXX
" only install the specified "XXX
" gem ? Are there any other difference? Why not use bundler to install specific rails then?
3. If I want to use rails v3.0 for project_one, and use rails v2.3 for project_two. How to create the two projects with the specific rails versions? How about different ruby versions for different projects? Do I only need to specify the needed version in Gemfile or install the needed version under the project path?
Upvotes: 1
Views: 193
Reputation: 450
1) If you have a rvm setup I propose add in in your app file .rvmrc and in that file:
rvm --create ree-1.8.7-2011.03@myappname
This will alway use specify version of ruby (in that case 'ree-1.8.7-2011.03') and all gems will be installed in rvm gemset named: myappname. This file will always make sure every time you go to that folder from bash_console it will point rvm to correct environment.
2) If you have rvm setup then:
gem install XXX creates gem in specify rvm gemset or if not global rvm gemset
sudo gem install XXX will add gems to you Global gems
Like you said, you should always use Bundle install, and group gems for development,test, production.
3) This can achieve like I said in point 1) just create this file in your app
Upvotes: 2
Reputation: 13463
RVM allows you to create different gemsets alongside different ruby versions.
You can install different versions of ruby with rvm install
.
rvm install 1.8.7
rvm install 1.9.2
rvm list known
will tell you the available ruby implementations you can install.
Say, you have two projects: project_one and project_two, and both of them have different gem dependencies. So you'll want to create two empty gemsets with, say, Ruby 1.9.2.
rvm gemset create 1.9.2@project_one
rvm gemset create 1.9.2@project_two
To use project_two's gemset, you can use rvm use
to select the gemset.
rvm use 1.9.2@project_two
You can also add the above command into a file called .rvmrc
in the root path of your rails application, which rvm will load automatically whenever you cd into the app's root directory.
If you want to use Rails 2.3.8 for project_one,
rvm use 1.9.2@project_one
gem install rails -v 2.3.8
and Rails 3.1.0 for project_two,
rvm use 1.9.2@project_two
gem install rails -v 3.1.0
The difference between gem install
and bundle install
is that gem install
installs only the specified gem into your gemset, while bundle install
installs all the gems located in your app's Gemfile
.
Upvotes: 6