Setting up Rails 3 on Ubuntu 10.10

by Andy Selvig 14. December 2010 12:07

In a previous post, I discussed being able to install Rails 3.0 on Ubuntu 10.04. Today, we'll talk about all the steps necessary to install Rails 3.0 and get it running on Ubuntu 10.10.

Let's start off by installing the necessary packages from apt-get:

sudo apt-get install ruby ruby-dev libsqlite3-dev rubygems


You'll notice that there are some standard ruby packages, as well as the development package for sqlite3. Since sqlite is the default database for new Rails apps, and a really handy development tool since it doesn't require you to setup and maintain a database server on you machine, we'll include this right off the bat. The development files are needed to build the native Ruby extension through rubygems.

Since Ubuntu 10.10 comes with rubygems 1.3.7, it is able to install Rails 3.0 directly, so we won't have to do any trickery like in the last article. We can move right on to installing Rails:

sudo gem install rails


This should list a bunch of gems that are needed by rails as they're being installed, along with the associated documentation. The builder gem's documentation generation might fail with an error, but don't worry. It will still function.

There's one more thing that we have to do before using Rails. Rubygems on Ubuntu installs the executable gem files in /var/lib/gems/1.8/bin, which isn't in your system path by default. This means that we can't run gem executables from the command line until it's added to our path. For a temporary fix, you can do:

export PATH=$PATH:/var/lib/gems/1.8/bin


For a more permanent solution, create a .bashrc file in your home directory and add the previous command to it:

echo 'export PATH=$PATH:/var/lib/gems/1.8/bin' > ~/.bashrc


This assumes that you don't already have a .bashrc file (if it's a fresh install of Ubuntu, you won't). If you do, append the command to the end of the file.

Now we have full access to our gems. To create a new Rails project, go the directory you'd like to have it in and type 'rails generate <app name>', like:

rails generate myapp


Now you can configure the gems you'd like for your app in the Gemfile. For example, say you'd like to be able to use Haml as a markup language instead of the default erb, simply add

gem 'haml'


to Gemfile. Once you're done (and whenever you change this file), run:

bundle install


to automatically install all of the gems the app needs.

Now you're set. To run your app, run:

rails server


and enter http://0.0.0.0:3000 into your browser. You should be greeted by the friendly default Rails page.

Tags: , ,

Comments

1/12/2011 8:11:52 AM #

wine shirt

Hay Andy Selvig,

Thanks for your suggestion. You solve my problem.

wine shirt United States | Reply

1/17/2011 8:32:04 AM #

Johnny

Thanks for posting this!

Johnny United States | Reply

9/16/2011 11:27:06 AM #

angle finder

Hi. I needed to drop you a fast be aware to express my thanks. Ive been following your blog for a month or so and have picked up a ton of excellent data and loved the method youve structured your site. I am making an attempt to run my very personal blog nonetheless I believe its too basic and I need to focus on a lot of smaller topics. Being all things to all folks just isn't all that its cracked up to be.

angle finder United States | Reply

10/1/2011 9:57:04 AM #

Gabriel Cole

Exceedingly beneficial appreciate it, I presume your current followers would likely want a lot more stories like this maintain the great effort.

Gabriel Cole United States | Reply

10/9/2011 1:37:50 AM #

Stainless Steel Valves

I generally approve with your ideas. We all benefit from this wonderful posting. This web-site is best. I have figured out some things from here. Thank you.

Stainless Steel Valves United States | Reply

10/13/2011 2:48:01 AM #

Fiberglass mesh

Oh, so unexpected, so surprise! Very touching, so well written and I have some perception, learning very much. Thank you for sharing. Very happy to see these and believe that your point of view.

Fiberglass mesh United States | Reply

11/28/2011 7:22:38 PM #

debt validation letter

I just came throughout this great internet site and need to express how grateful I’m to you for sharing this wonderful information.

debt validation letter United States | Reply

1/11/2012 10:52:42 PM #

plumber frankston

A lot of thanks for posting this article I just want you to know.. that I’m just reading your site it is really worthy and informative for me.

plumber frankston United States | Reply

1/13/2012 12:30:17 AM #

sarees

this post very nice.

sarees India | Reply

2/20/2012 6:13:44 AM #

Snorkeling in Singapore

After I read your post, I told my co-worker immediately, what a great read.

Snorkeling in Singapore United States | Reply

4/24/2012 10:47:42 AM #

Promo code

thanks MR, i am totally agreed with you

Promo code United States | Reply

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Page List