Upgrade Rails to latest version - ruby-on-rails

I'm new to the Ruby on Rails environment and would like to get input in relation to upgrading my Rails environment from 4.0.2 to 4.2.3, which I assume is the latest version.
My Ruby version is 2.0.0p353 (2013-11-22) [i386-mingw32].
Is upgrading a straight-forward process? If not, what is the upgrade path I need to follow?
I normally use bundle install cmd to install all gems. Is there a similar command to upgrade to the latest version?
Do I need to backup my apps before I try anything?

In your gemfile change:
gem 'rails', '4.0.2'
to
gem 'rails', '4.2.3'
and in your terminal run bundle update.
If you are trying to update ONLY Rails, run: bundle update rails.

Related

rails -v keeps saying Rails 3.2.13 after installing 4.2.2

What gives?
I typed this in gem install rails -v 4.2.2
After that, I tried rails -v, and it keeps coming out Rails 3.2.13
Why is this?
My ruby version after ruby -v
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
You can manage gems with bundler (http://bundler.io/)
Put this on your Gemfile
source 'https://rubygems.org'
gem 'rails', '4.2.2'
gem install bundler
and then
bundle install
bundle exec rails -v
If you still working without bundler, you can make
gem list
look at your rails version and then uninstall older versions
gem uninstall rails --version 3.2.13
and then
rails -v
I've encountered this before. And this is what I did.
Change version of rails
Just change the versions.
If you have multiple versions of Rails installed, you'll get conflicting information like this.
If you need to run a command with a specific version of Rails, you can specify the version as part of the command, eg.
rails _4.2.2_ -v
That will tell you you are using Rails 4.2.
Once you've created a new app by doing something like rails _4.2.2_ new app_name, then the Gemfile for that app will specify Rails 4.2.2 and you can drop the special prefix.

How to downgrade my rails version?

I am using rails version 4.2.0. How can I downgrade to version 3.2.19?
I tried the following:
I opened command prompt.
I typed gem uninstall rails
Some options came for rails version then I selected my current version and pressed entered.
Then typed gem install rails -v 3.2.19 for installing this version.
I went to my Site directory and typed rails new blog
When I opened the Gemfile of blog application I found again Rails version 4.2.0 is present there.
Do:
gem uninstall rails
gem uninstall railties
Followed by:
gem install rails -v 3.2.19
To check a rails version, directly do:
rails -v
Another workaround:
add following to your Gemfile:
gem 'rails', '3.2.19'
and then run:
bundle install
Or you dont have to downgrade. You can always create a new rails app with a specific version(if that version is already installed)
rails _3.2.19_ new myApp
That is not good approach to uninstall a global version of Rails. So just create a Rails app:
rails new app
then change Rails version in its Gemfile, and issue bundle install:
cd app
sed "s/'rails', '~> 4.2.0'/'rails', '~> 3.2.19'/" -i Gemfile
bundle install
Then, I believe, you should change all the dependent packages to older versions.

"Rails is not currently installed" Error

Hi i'm new to ruby on rails
I have 3 ruby version in my computer.
In a project i had to use rails 3.2.1 and ruby 1.9.2
So I switched using rvm use 1.9.2 in terminal. But after that my rails commands are not detected.
$ rails g model abc
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
Why is this happening? And how to solve this?
You may need to differentiate your gem set that contains that specific version of rails from the old ones.
rvm use 1.9.2#new_gem_set_of_yours --create --default
And then retry installing the 3.2.1 rails
gem install rails --version 3.2.1
Or specify the new rails version in your Gemfile and let Bundler take care of it
gem 'rails', '3.2.1'
and run bundle install.
Type in your terminal
gem install rails -v 3.2.1
if it does not work, first try
rvm install 1.9.3
then
rvm rubygems current
and repeat.

Change version of rails

I accidentally changed my rails version to 4.0.0. I've tried gem uninstall rails --version=4.0.0.rc1 and install version 3.2.13 but when rails -v it's still version 4.0.0. I then tried gem uninstall rails, which gives me "Successfully uninstalled rails-3.2.13". Thought this was easy to do, but I can't find a simple solution.
Try this:
rvm use <ruby version>
You can also check your installed ruby versions using rvm list and then switch over. Then do:
rvm gemset create rails3.2.13
rvm <ruby version>#rails3.2.13
gem install rails --version=3.2.13
Remove your Gemfile.lock and install rails again. Make sure you specify the version of Rails.
source 'http://production.cf.rubygems.org'
ruby '1.9.3'
gem 'rails', '3.2.13'

How do I upgrade to the latest version of ruby on rails 3.2.8?

I've been away from programming for a few months but I'm back now and surprised to rails already at version 3.2.8. I feel slightly rusty and forgot how to successfully upgrade my ruby on rails version to the latest.
I'm currently using version 3.2.3
Is there a standard way of upgrading? I remember the last time I upgraded I had to modify some lines in the gemfile. A google search didn't help so I would appreciate a solution from my favourite place thanks.
Kind regards
If you just want to install the latest rails gem
gem install rails -v 3.2.8
If it's a rails 3.2.3 app
Edit Gemfile, changing the line gem 'rails', '3.2.3' to gem 'rails', '3.2.8'
Run bundle update rails
(from this so question)
For each app you want to upgrade:
Gemfile
gem 'rails', '3.2.8'
# ...
Then on the command line:
$ bundle update rails

Resources