简体   繁体   中英

Finding the right version for Rails on Ubuntu 12.04

I installed rails using apt-get install rails .

When I run a rails server command, Rails creates a project called 'server'. After Googling, I found that my version should be old and so I was supposed to run script/server or script/generate .

So, I want to upgrade Rails correctly because a lot of things seem to be deprecated, but my version is Rails 2.3.14 (and Ruby is 1.8.7). How to upgrade Rails ? If done, would that match with this version of Ruby?

Have you tried sudo gem install rails to upgrade to the most recent version?

To upgrade Ruby check your apt-cache to see what the most recent version available to you is. If it's newer than what's installed you can use apt-get to install it.

Or, as recommended, you could use RVM to manage your Ruby installation(s). Follow the installation directions carefully -- people often do a partial install because they didn't read the directions and do what is needed, and end up with a non-functioning RVM installation.

Personally, I often install from source for my production hosts, but on my development hosts use RVM or rbeenv to allow me to run multiple versions of Ruby in my own sandbox.

I'm purposely being a little vague. All the information you need to do what you want is easily available on the web and can be found with a minimum of effort on your part. For instance, there's " Upgrading rails to the latest version from 2.3.5 ".

When I install rails on any debian-based distribution (Ubuntu is debian-based), I haven't found a better guide than Ryan Bigg's tutorial on installing Rails for Ubuntu . Sure, it says it's for Ubuntu 10.10, but all the commands should work for 12.04 as well (as far as I know). This tutorial also follows best-practices (like installing a version manager for ruby, which is immensely helpful when you start developing more than one rails app).

I would recommend you remove your current rails install before following the tutorial to make sure that there are no problems:

sudo apt-get purge rails

That will remove the old rails package and any config files it made. When following the tutorial I linked above, you can select and copy the command from the tutorial like normal and paste them into the command line with Shift+CtrL+V . However, it's much more helpful from a learning perspective to type the commands out yourself . Make sure you understand what each command is doing when you run it. Just to clear this up, ruby is a program that you install on your computer so it can understand the ruby language (not a gem). Rails is a gem, so you don't install it the same way as other programs. All gems are installed using the gem install or bundle install commands.

At the end, it also includes some notes about installing MySQL or Postgres, which can be a little tricky sometimes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM