Replace Taobao image
Due to the domestic network (you know), the resource files stored by rubygems.org on Amazon S3 fail to connect intermittently. Here, the default image should be changed to the image of Taobao.
gem sources --remove https://rubygems.org/
Managing multiple versions of gem using bundler
With rbenv to manage multi version Ruby environment, we also need a tool that can manage multi version gems (such as rails), that is bundler. The project background is not detailed. What we need to know is directly to the official website. Here we only talk about some practical experience
gem install bundler
mkdir app1; cd app1; echo "source 'https://ruby.taobao.org/'" > Gemfile echo "gem 'rails,'4.1.0'" >> Gemfile bundle install
The above code installs rails 4.1 under app1 0. Use bundle exec rails – V to view the rails version used in the current directory. The display content should be rails 4.1.0 0, also through bundle exec rails new– Force overwrites the original gemfile. At this time, the rails version used by the app is 4.1 0
mkdir app2; cd app2; echo "source 'https://ruby.taobao.org/'" > Gemfile echo "gem 'rails,'3.2.13'" >> Gemfile bundle install
The above code creates the second app2 folder and installs rails 3.2.0 through bundler 13. Also use bundle exec rails new– Force can generate data based on rails 3.2 Application of version 13
After installing the above two versions, you can see that there are two versions of rails through gem list — local, which are displayed as rails (4.1.0, 3.2.13). Bundler will intelligently judge the rails version of each project to ensure the correct operation of the application, but the premise is to execute the original command by using the bundle exec command, for example:
bundle exec rails s bundle exec rake db:create ...