Zhixian's Tech Blog

2015-10-30

hellorails

Filed under: Uncategorized — Zhixian @ 23:06:10 pm

This blog is about creating a first Rails web application.
Before proceeding, you need to install sqlite.

Summary of Steps

  1. Install sqlite
  2. Install nodejs
  3. Create hellorails
  4. Running hellorails

Install sqlite

To install sqlite, run the follow commands:

$ sudo apt-get install sqlite3
$ sudo apt-get install libsqlite3-dev

Note: We have to install libsqlite3-dev because we want to use add sqlite support to Rails via gem.

After sqlite is installed, we can add sqlite support to Rails by running the following command.

$ sudo gem install sqlite3 -v '1.3.11'

Install nodejs

Rails do not a built-in web server. It relies on other infrastructure to run. Here, I decide to install nodejs as I am intending to do some other nodejs development later on as well.

$ sudo apt-get install nodejs
$ sudo apt-get install npm

Creating hellorails

After all the setup is done, we can start to create our hellorails application by running the following command:

sudo rails new ./hellorails

Running hellorails

After the application is created, navigate into the directory.
You can run the application by running the following command:

$ rails server

Note: This command will start a web server listening on localhost on port 3000. What this means, is that you can only access the web application on your local machine. To allow other machines to access the web application on port 3000, you need to make the web server listen to the IP address of 0.0.0.0. This can be done by running:

$ rails server -b 0.0.0.0

An alternative to adding the parameter is edit boot.rb file in the config folder.

Reference

http://guides.rubyonrails.org/initialization.html

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: