Changing default rails in ubuntu - ruby-on-rails

I am working on Ubuntu . Initially I have 3 version of rails installed 3.2.9 , 3.2.12 and 4.0.0 . Running rail -v was showing Rails 4.0.0 . I tried to uninstall Rails 4.0.0 using gem uninstall rails 4.0.0 . Now Running gem uninstall rails gives this output:
Select gem to uninstall:
1. rails-3.2.9
2. rails-3.2.12
Running rails -v now also gives Rails 4.0.0 .Any guesses how can i change default rail to 3.2.12.

Investigating more on Thaha kp comment, I found this:
rails _3.2.12_ new myapp # slightly different version positioning
that means, you can install as many rails versions you want in one ruby environment, and when you start a new app you just need to specify what version to use.
Now if you started your app in rails 3.2.10 and want to upgrade to rails 3.2.11 you just change the version in your Gemfile as Bharath Sankar suggested, after a running bundle your app will use 3.2.12 version.

Related

Rails: using rails 5 and generating rails 4 template app

My machine is using Rails 5. Because some business, I must create new rails 4 application. I have using following syntax for generating rails 4 app:
rails _4.2.3_ new demoapp
Nevertheless, new application structure is built for rails 5. My question is: how can I use rails 5 for generating rails 4 structure app.
Thanks
First of all try to find out if you have that version installed. In this case, run this command:
gem list rails
You should see the list of gems you have installed on your computer that contains the word 'rails' in the name and also you will see the version (or versions) of that gems that you have installed.
Find where does it says rails and there you will find all the versions you have installed, in my case it is: rails (5.2.0, 5.1.6, 5.1.4, 5.1.3, 5.1.2, 5.1.1, 5.0.6, 5.0.3, 5.0.1, 5.0.0.1, 4.2.0)
So I can run the command rails _4.2.0_ new myapp and it will create a new app using rails 4.2.0.
If you don't have that version installed just run the command gem install rails -v 4.2.3
And there you have it.
References:
Specifying rails version to use when creating a new application
How to install a specific version of a ruby gem?

rails -v returns 2.3.5 but gem uninstall rails offers to uninstall version 3.1

I am trying upgrade Rails. I am pretty sure that Rails 3.1 is now installed, however my rails apps still have no Gemfile, and rails -v returns 2.3.5. When I type "gem uninstall rails" I get:
aheine#ubuntu:~/www$ gem uninstall rails
Select gem to uninstall:
1. rails-3.0.9
2. rails-3.1.0.rc1
3. rails-3.1.0.rc5
4. All versions
How can I get rid of Rails 2, and make rails 3 the default version to use?
I am using Ubuntu 11.04
Your running with the system provided Rails, run apt-get remove rails and then you may need to make a configuration change so the system can find the proper rails command. So see if that works and then try running rails -v if that returns command not found add this line to the beginning of your .bashrc file in your home directory.
export PATH=/var/lib/gems/1.8/bin:$PATH
After that's done open a new shell and try running rails -v again.

How do I upgrade from Rails 2.3.5 to Rails 2.3.8?

I've got a Rails 2.3.5 app that I want to upgrade to Rails 3. In the Rails 3 upgrade Railscast, they suggest upgrading to 2.3.8 before going to 3. I've tried Googling but the information I find is all about upgrading to Rails 3. I found this question, which seems to suggest doing gem update rails and rake rails:update, but wouldn't these commands upgrade to Rails 3, as it's the latest version? How do I upgrade to Rails 2.3.8? Thanks for reading.
There's not much difference between 2.3.5 and 2.3.8 (also, 2.3.10 is the latest version on the 2.3 branch - you should upgrade to that).
Install Rails 2.3.10:
gem install rails -v=2.3.10
Then edit config/environment.rb and change your Rails version to 2.3.10 near the top of the file. Start up webrick, deal with any deprecation warnings it throws at you while you click through your app, and you're pretty much done.
Citation from the Rails blog:
"We’ve released Ruby on Rails 2.3.9
(gem and git tag) to extend the 2.3.8
bridge a few steps closer to Rails 3
and Ruby 1.9. If your app runs on
Rails 2.3.9 without deprecation
warnings, you’re looking good for an
upgrade to Rails 3."
Edit:
Jeremy is on the money. Don't install 2.3.9, it has a serious security flaw. I've updated my answer to 2.3.10.
You can run rake rails:update - this updates the stock javascripts and config files. However, they probably won't need to be changed from 2.3.5 to 2.3.10.
$ gem install rails -v 2.3.8
Then change the RAILS_VERSION in your environment.rb file and run
$ rake rails:update

How do you change Rails version on a mac?

I've got Snow Leopard with Rails 2.3.5 installed along with other versions (2.2.2 and 1.2.6). I'd like to use 2.2.2 as the webserver I want to deploy to uses a 2.2.x version of Rails. I've tried to uninstall Rails 2.3.5 but get this error:
ERROR: While executing gem ... (Gem::InstallError)
cannot uninstall, check `gem list -d rails`
Is there any other way of setting the Rails version to one of the other installed Rails versions?
You should really take look to RVM(Ruby Version Manager) it's awesome!
https://rvm.io
http://teachmetocode.com/screencasts/rvm-ruby-version-manager/
Cheers
Denis
You should be able to do this without needing to uninstall anything. You can specify the version of rails you want to create an application for by typing the following when creating a new app.
rails _2.2.2_ app_name

How can I create previous version rails in rails 3?

I've just upgraded my rails version to rails 3.0.
But suddenly I need a new rails app with old version of rails.
I know the new version of rails change command line usage with rails new.
How can I create an old version of Rails in this new Rails 3 environment?
Use the following command:
rails _2.3.5_ new APP_NAME
This will create a rails project with version 2.3.5
Leonid Shevtsov provided instructions for how to do this here.
The easiest way to do it was:
Create the directory for the project
Create a Gemfile there containing
gem "rails", "2.3.9"
gem "sqlite3-ruby", :require => "sqlite3"
Runbundle install
Run bundle exec rails . to create an app in the current path
You don't even need rvm to do this.
If you need to switch back and forth, I would recommend using RVM. You can install different versions of Ruby and each can have its own set of gems. I use my system installed ruby (1.8.6?) on my Mac for Rails 2 dev, and then I installed Ruby 1.9.2 with RVM for my Rails 3 dev. Its as simple as doing this after you have RVM installed:
#install and use 1.9.2 for Rails 3
rvm install 1.9.2
rvm 1.9.2
rails new whatever
#switch back to system installed ruby for Rails 2
rvm system
rails whatever

Resources