downgrading rails 4 to 3.2 - ruby-on-rails

I have the Rails 4.0.0.beta1 installed but I need downgrade to Rails 3.2.13.
I've used gem install rails 3.2 but Rails continues as 4.0.0.beta1.
I searched existing doubts and try to follow the answers however none worked for me.
Think this is a simple doubt and I need to solve.
This answer my question: How to set default rails version for a project?

You have the same problem as listed here.
Here is what worked for me, and should also for you. It's a more general solution that works regardless of your specific version of the Rails beta. Please note that in order to shift back to 3.2.13 (or whatever version you'd like to go back to), you must remove Railties as well as Rails.
Just do:
gem uninstall rails
Then, select the version of Rails 4 you have and delete it.
Then, do:
gem uninstall railties
And do the same thing.
When I uninstalled the Rails 4 version of railties, it told me that dependencies for a couple gems (coffee-rails and sass-rails) wouldn't be met. So I just did the same thing with both of them as I did above, and deleted their Rails 4 versions as well (for example, for sass-rails, I had a version installed called sass-rails-4.0.0.rc1).
And done! The terminal should list 3.2.13 as your current Rails version.

Unless you're using bundle exec, Rubygems will always use the latest installed version of a gem. You need to uninstall the version you don't want.
gem uninstall rails --version 4.0.0.beta1

The answers to gem uninstall rails --version xxx should remove the rails gem just fine.
However, in the event you want or need to have multiple versions of rails available simultaneously, you can use bundler to load the correct versions of gems (as intended).
$ bundle exec rails in the project directory that lists the version of rails in the Gemfile should let you load the required gems without conflict.
Additionally, rvm and its gemset feature could also let you accomplish the same goal without needing to wrap everything with a bundle exec

Rails will use the version specified in Gemfile:
gem "rails", "4.0.0.beta1"
Replace it with the version you'd like to use instead:
gem "rails", "~> 3.2.0"
Of course, you will also need to change your code and config to use the old Rails API.

I had the same problem with Rails 4.0.0 final version. To check what is currently installed you can run the following:
>pik gem list
Then I checked the rails versions. It showed rails 3.2.14 (what I wanted) with railties 4.0.0, 4.0.0.rc2 and 3.2.14.
I then ran
>gem uninstall railties
and uninstalled all other versions except 3.2.14 and now it works well. The problem was that when Rails 3.2 installation is called, the latest (or all) versions of railties is installed.
If you have other versions of rails other tan the one you want, you can removed them with
>gem uninstall rails
and remove the versions of rails you do not want to have.

Try the following in your console. It will update or install rails to the specified version.
gem update rails 3.2.13

Related

Do I have to install Ruby from source to get Ruby 2.2.0 and Rails 4.2.0 installed on my windows machine?

I currently have Ruby 2.2.6 and Rails 5.0.1 installed on my Windows 10 machine. I have cloned an existing project that has the following settings included in its Gemfile:
# Lock-in Lang and Framework:
ruby '2.2.0'
gem 'rails', '4.2.0'
I'm having a surprisingly hard time figuring out how to get Ruby 2.2.0 and Rails 4.2.0 installed. Ruby has good documentation of different installation options, but I think I've exhausted the Windows options without any success. Here are a couple I tried:
Installers: I couldn't find an option for downloading either from RailsInstaller, RubyInstaller, and Bitnami.
RVM: I tried (unsuccessfully) following this blog post to install cygwin so that I could use RVM, but then saw in the comments that the author now recommends spinning up a linux VM rather that using this method.
Pik and Uru: It appears Pik is no longer maintained, and I couldn't figure how to download new versions and ruby and rails with Uru as opposed to managing already downloaded versions.
EDIT: I also tried simply changing the version numbers for ruby and rails in the Gemfile to 2.2.6 and 5.0.1. When I do this I (very understandably) get a message when I try to use a rails command saying I need to run bundle update rails. When I run that rails update I get the following error: Bundler could not find compatible versions for gem "rack". I've done some googling on that option, and it looks like resolving that issue might be possible but requires some more involved tinkering with my Gemfile configuration.
I think my next option is to install Ruby from the source, but I wanted to throw a question up here first to make sure I'm not missing an easier method. So my question is - is it really this hard to get an older minor release of ruby and rails installed on Windows? I realize that the majority of users are probably looking for the most recent release, but it doesn't seem to me that my use case is terribly unique.
The oldest available Ruby 2.2.x via RubyInstaller is 2.2.1
So, the answer to your question is, "Yes, you'll have to build from source."
But then again,
v2.x of gem "rack" requires at least Ruby v2.2.2
And depending on what other gems are included in your Gemfile, you'll still have to reconfigure your Gemfile to get this app running.
So the best solution is probably to use the latest patch version of Ruby 2.2.x and lock rails to 4.2.x. (The app may not be compatible with Rails 5.x)
# Lock-in Lang and Framework:
ruby '2.2.6'
gem 'rails', '~> 4.2'
Then run bundle install to install all the gems required by the Gemfile

ActionCable without upgrading to Rails 5 beta

I currently have a Rails app running on 4.2.5, and I want to use ActionCable without having to upgrade the whole thing to the Rails 5.0.0.beta3 version and risk breaking all of the other gems.
Following guides I've seen on the internet, I've tried
gem 'actioncable', github: 'rails/actioncable'
which doesn't work because the ActionCable repo has been merged into the Rails repo. I even tried
gem 'actioncable', github: 'rails/rails'
but this doesn't seem to work of the re-numbering of the versions that happened when ActionCable merged into Rails. (The only version below 5.0.0.beta* is the 0.0.0, which seems to be an empty gem.)
I also tried setting the source to rubygems.org in hopes of finding an older pre-merged version, but was unsuccessful.
What can I do to integrate ActionCable into my 4.2.5 project without upgrading to Rails 5?
Conversely, when could we anticipate the first stable release of Rails 5? :)
You can have both GemSets, so you can use rails 4 and rails 5 whenever you want.
First, update the ruby gem manager by $ gem update --system, install Nokogiri if you haven't $ gem install nokogiri.
Now lets set your rails 4 GemSet (you might have to update ruby, it will tell you if you need to)
$ rvm use ruby-2.3.0#rails4.2 --create
$ gem install rails --version=4.2.5
$ rails -v
your rails version should be 4.2.5 at this point.
Now lets set your rails 5 GemSet
$ rvm use ruby-2.3.0#rails5.0 --create
$ gem install rails --pre
$ rails -v
your rails version should be 5 beta3 at this point.
We are done, now you only need to change between GemSets, depending on your needs, by doing this.
for rails 4 use = $ rvm use ruby-2.3.0#rails4.2
for rails 5 use = $ rvm use ruby-2.3.0#rails5.0
Now, you can use and experiment rails 5 without risking your rails 4 gems and stuff.
You can do exactly the same for other Rails versions if you want.
I have same issue,But i solved.just check this
Just try your rails console
check your rails version rails -v
may be rails (4.2.7.1)
Then you need to check gem list, i mean gem list -l
Now you can see your all gem with versions.
Then you need to instsll gem install rails -v 5.0.0beta2
once installed rails check gem list, gem list -l
Then you can see rails (5.0.0.rc2, 5.0.0.beta2, 4.2.7.1)
You successfully installed rails 5.0.0
Then you do bundle update
Update all gem and supporting rails 5.0.0,this is work for me just try this.

I am having trouble uninstalling Rails 4.1.5 and installing Rails 4.0.8

I tried uninstalling Rails 4.1.5 by doing "gem uninstall rails" and then installing Rails 4.0.8 by doing "gem install rails --version 4.0.8". However, now when I try to see what version of Rails I am using by doing "rails -v" I still get "Rails 4.1.5". How do I fix this?
I know I'm a bit late however I am answering in case others need an answer of how to manage gem versions. The linked duplicate question offers a perfectly fine answer to the question but does not give guidance to how to easily manage this long term. I do the following before starting every new project.
First you need rvm to manage ruby versions and create gemsets. With gemsets you can create isolated groups of gems that are project or ruby or rails version specific (it's up to you how you organize yourself).
After installing a version of ruby to use you create a gemset and tell your system to use this version of ruby with this gemset.
Then select the gemset and install the version of rails you want to use into the gemset. You will also need to install bundler into the gemset.
Once you have this setup you can insert the following lines into your rails gem file to tell this project which ruby version, rails version and gemset to use (in my example I am using ruby version 2.1.5 with the gemset named scan and the rails version 4.0.8)
ruby '2.1.5'
#ruby-gemset=scan
gem 'rails', '4.0.8'
Then cd into the rails project directory and run bundle install. Bundler will install the gems from your project's gem file into the selected gemset. Now you have an isolated and stable system for the project. If you have another project with different ruby version, rails version and gemset any changes there will not affect anything here.
For more details on how to setup rvm just go to the website and read the documentation. It's really easy to use and will save you many headaches.

Is a double Rails install possible?

I started to learn Ruby on Rails while ago so now I am going back and starting again. I have found that I do not have rails installed but I do have jewellery box and ruby installed. Will installing the rails installer again effect these or just add rails?
Thanks
You just need to read about bundler. You may have any versions of any gems at the same time using bundler and rails currently (from v 3.0) build on top of bundler.
It will just add rails. You can also have separate gemsets that all contain their own rails installs that can have their own versions and stuff. Short answer though is that it will just add rails.
It depends on rails version in your Gemfile (or when installing via gem install). If version isn't specified then it will be updated to latest after each bundle install.
In addition to specifying the rails version, I would recommend to use RVM (http://rvm.io/) for delimiting different gemsets for different applications.

Could not find a valid gem 'rails' (= 3.2.0) in any repository

I'm installing ruby on rails on my OS X 10.7 machine and trying to follow along with this book: Agile Web Development with Rails.
Anyway I have installed Ruby 1.9.3 and then ran gem install rails and it pulled down rails 3.1.3, now the book says when I run 'rails -v' I should get 3.2.0 or NEWER.
I checked out http://rubygems.org/gems/rails and it says the latest version is rails 3.2.0 RC2, how is it that the book specifies (in multiple places to it's not a typo) that it should be 3.2.0 or NEWER when 3.2.0 isn't even released?
Actually, if you want the latest unstable version, run this:
gem install rails --pre
It'll install the latest RC.
EDIT: as to why the included 3.2.0 when it is not out yet, I can't answer for them! Maybe you have a "beta" version of the book?
Looks like you're specifying an explicit dependency on a future version of Rails, probably something like gem 'rails', '3.2.0'. If you indeed want to use this version, you'll have to settle for one of the release candidates for now:
gem 'rails', '3.2.0.rc2'
Or borrow a time machine.

Resources