searching for an answer to the question above in Stackoverflow I have always bumped into a similar - but not equal - question: whether it is possible to create a new rails app with an older version than the latest installed on the computer (one of the most popular posts of this kind is Specifying rails version to use when creating a new application). However, what I'm interested in is knowing if it's possible to run a command such as 'rails __2.1.0__ new myapp' even if that specific rails version is not yet installed on my computer so that when it runs it it automatically installs this rails version plus it creates all the starting files (in which the Gemfile contains all the compatible gems of that specific version already).
As an example... Right now I'm following the Rails Tutorial book by Michael Hartl and we are asked to use the ruby version 2.0.0, the rails version 4.0.8 and to include the following info into the Gemfile:
source 'https://rubygems.org'
ruby '2.0.0'
#ruby-gemset=railstutorial_rails_4_0
gem 'rails', '4.0.8'
group :development do
gem 'sqlite3', '1.3.8'
end
gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
It happens that I have by default ruby-2.1.2 and rails 4.1.4 so when I have wanted to follow Hartl's book I have had to create a new rails application (which sets up the Gemfile according to rails 4.1.4) and after that I have had to cd into the new app, run $ gem install rails --version 4.0.8 to install the version, substitute the default Gemfile that came with rails 4.1.4 for the above code, then run bundle install and bundle update.
It seems to work, but all in all it is a rather tedious and annoying solution. Couldn't this be solved, like I wrote at the beggining, with a 'rails ____2.1.0____ new myapp' in which version 2.1.0 (that I do not have installed) gets installed at that moment?
I'm sure there has to be an easier way to get started with a different rails version project, I just don't find it or try to solve it with the wrong commands. I'm sure the solution I implemented wasn't good enough either since whenever I try to create another rails app using a version that I have allegedly already installed (2.0.0) this is what I get from the Terminal:
Desktop$ rails _2.0.0_ new myapp
/Users/gaa/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:313:in `to_specs': Could not find 'railties' (= 2.0.0) - did find: [railties-4.1.4,railties-4.1.1] (Gem::LoadError)
Checked in 'GEM_PATH=/Users/gaa/.rvm/gems/ruby-2.1.2:/Users/gaa/.rvm/gems/ruby-2.1.2@global', execute `gem env` for more information
from /Users/gaa/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:322:in `to_spec'
from /Users/gaa/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:53:in `gem'
from /Users/gaa/.rvm/gems/ruby-2.1.2/bin/rails:22:in `<main>'
from /Users/gaa/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
from /Users/gaa/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'
I would really appreciate a helping hand.