Let's talk Contact us. No cost. No obligation.

Fill out this form and we will contact you with in 24 hrs.

Knowledge Base

How to Create an Application in Rails 3

April 21, 2014

Following are the steps for creating an application in Rails 3:

Installing Rails

In most cases, the easiest way to install Rails is to take advantage of RubyGems:

Usually run command as the root user:

$ gem install rails

To verify that you have everything installed correctly, you should be able to run the following:

$ rails —version

Creating the Blog Application

To begin, open a terminal, navigate to a folder where you have rights to create files, and type:

$ rails new blog

This will create a Rails application called Blog in a directory called blog.

Configuring a MySQL Database

If you choose to use MySQL instead of the shipped SQLite3 database, your config/database.yml will look a little different. Here’s the development section:

development:

adapter: mysql2

encoding: utf8

database: blog_development

pool: 5

username: root

password:

socket: /tmp/mysql.sock

Command for create application with mysql application

$ rails new blog –database=mysql

After you create the blog application, switch to its folder to continue work directly in that application:

$ cd blog

$ rake db:create

$ rails generate scaffold Post title:text body:text

$ rake db:migrate

$ rails server or rails s

Now browse

http://localhost:3000/posts