Wednesday, May 30, 2012

Rails - to create a blog site Part 1

Tutorial that I am following is from this site : http://guides.rubyonrails.org/getting_started.html


I choose to sudo as root to avoid the permission issue.
$ sudo su 

Install Ruby
$ apt-get install rubygems

Install Rails
$ gem install rails

Create a blog application
$ rails new blog

Note : You might encounter this error.
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension

To solve this, install sqlite before create the blog application.
$ apt-get install libsqlite3-dev
$ gem install sqlite3 -v '1.3.6'

Create a database
$ rake db:create

You might encounter this error.
rake aborted!
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.

Go to the created blog directory. Edit this file : Gemfile.
Uncomment this line :
gem 'therubyracer', :platform => :ruby
Run this (installing nodejs and also reinstall rails) :
$ apt-get install nodejs
$ bundle install

To start the web server
$ rails server

You can access the new project site at http://0.0.0.0:3000.


P/S : I am running on Ubuntu 12.04.

1 comment:

  1. This is a lengthy tutorial that I've learned from, but covers almost everything in the latest rails and some useful gems.
    They takes you through setup of rails on local as well as production with heroku, test driven dev and deployment:
    http://ruby.railstutorial.org/book/ruby-on-rails-tutorial

    FYI, I never finish it :-P

    ReplyDelete