SimplerCloud Pte Ltd

×
×

How to create your first Rails application?

Back

Note that MySQL is pre-installed on your Ubuntu + Ruby on Rails OS platform, and we strongly recommend you to use MySQL rather than the default SQLite.

To create your Rails application (e.g. on "myapp2" folder):

rails new myapp2 -d mysql

Go into the application directory:

cd myapp2

Modify the content of config/database.yml to contain the username and password to MySQL database. The default username is "root" while the default password is "S1mplerCloud" (without the quotes). Use your favourite editor to modify the file:

vi config/database.yml

or

nano config/database.yml

===
default: &default
  adapter: mysql2
  encoding: utf8
  pool: 5
  username: root   password: S1mplerCloud   socket: /var/run/mysqld/mysqld.sock
===

Create the database for the application:

rake db:create

Finally, run the Rails application framework:

rails server -b 0.0.0.0

For example:

root@Ubuntu14042-64b-RubyRails:~/myapp2# rails server -b 0.0.0.0
=> Booting WEBrick
=> Rails 4.2.0 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2015-06-05 16:07:39] INFO  WEBrick 1.3.1
[2015-06-05 16:07:39] INFO  ruby 2.2.1 (2015-02-26) [x86_64-linux]
[2015-06-05 16:07:39] INFO  WEBrick::HTTPServer#start: pid=2712 port=3000

You should be able to access the Rails application using web browser by pointing to your servelet's IP address on port 3000. For example:

http://[IP-ADDRESS]:3000

To close the Rails application, just press Ctrl-C.

Was this article helpful?
Dislike0 Like0
Views: 842