How to Create and Deploy a Simple Ruby on Rails Application
Sign Up for a free account on Cloud9., Go to your Dashboard and click "Create a new workspace". , Name the workspace as desired., When the workspace is ready, select the workspace and click "Start Editing". , Click on "+" sign to open...
Step-by-Step Guide
-
Step 1: Sign Up for a free account on Cloud9.
Cloud IDE comes with pre-configured tools for Rails App Development. -
Step 2: Go to your Dashboard and click "Create a new workspace".
, Check "Private to the people I invite".
Click on "Rails" icon (not Ruby on Rails icon).
Click Create. ,,
-v denotes the version. , This will create a new app named "hello_world".
You will notice a new directory created with the name "hello_world" in the workspace. ,, end , After "Rails.application.routes.draw do"
add a line " root 'application#hello' ".Save the changes by "Ctrl + S". ,, To do this, click on the "+" sign on the terminal window and choose "New Terminal".
Start Rails server by running the command " rails server
-b $IP
-p $PORT". , Your application should display "Hello World! ". , Git helps in version control. ,, To do this, use the commit command: git commit
-m "Initialize repository"
, Run "cat ~/.ssh/id_rsa.pub" command.
It will give you your public key.
Add your public key to Bitbucket by clicking on the avatar image in the upper right and selecting “Manage account” and then “SSH keys”.
After adding the key, click on “Create” to create a new repository.
Fill the name and click "Create Repository". , Run the commands as given in the instructions.
It will be something like below: git remote add origin [email protected]:/hello_world.git git push
-u origin
--all ,, Run bundle install with a special flag to prevent the local installation of any production gems. "bundle install
--without production"
,, Fill in the correct details with which you have created your Heroku account. ,, It creates a new subdomain just for our application, available for immediate viewing. ,, Our newly created "Hello_World" App is live on the internet. -
Step 3: Name the workspace as desired.
-
Step 4: When the workspace is ready
-
Step 5: select the workspace and click "Start Editing".
-
Step 6: Click on "+" sign to open terminal.Install Rails by typing "gem install rails -v 4.2.0" in the terminal window."
-
Step 7: Run "rails new hello_world" in the terminal.
-
Step 8: Open the file application_controller.rb by going to "app/controllers/application_controller.rb".
-
Step 9: Add the following code after "protect_from_forgery with: :exception" statement : def hello render text: "Hello world!"
-
Step 10: Open file "config/routes.rb".
-
Step 11: Change current directory to "hello_world" by running "cd hello_world" in the terminal.
-
Step 12: Open a new terminal.
-
Step 13: Go to Share and click on the Application address to open it.
-
Step 14: Initialize a git repository by running "git init" in the terminal.
-
Step 15: Add all the project files to the repository using "git add -A".
-
Step 16: Tell Git you want to keep the changes.
-
Step 17: Create a Bitbucket Account.
-
Step 18: Add your Public Key to Bitbucket.
-
Step 19: After clicking “Create repository”
-
Step 20: follow the instructions under “Command line > I have an existing project”.
-
Step 21: Open the 'gemfile' in the "hello_world" directory and update it with the following code: source 'https://rubygems.org' gem 'rails'
-
Step 22: '4.2.0' gem 'sass-rails'
-
Step 23: '5.0.2' gem 'uglifier'
-
Step 24: '2.5.3' gem 'coffee-rails'
-
Step 25: '4.1.0' gem 'jquery-rails'
-
Step 26: '4.0.3' gem 'turbolinks'
-
Step 27: '2.3.0' gem 'builder'
-
Step 28: '2.2.3' gem 'docs'
-
Step 29: '0.4.0'
-
Step 30: group: :doc group :development
-
Step 31: :test do gem 'sqlite3'
-
Step 32: '1.3.9' gem 'bye bug'
-
Step 33: '3.4.0' gem 'web-console'
-
Step 34: '2.0.0.beta3' gem 'spring'
-
Step 35: '1.1.3' end group :production do gem 'pg'
-
Step 36: '0.17.1' gem 'rails_12factor'
-
Step 37: '0.0.2' end
-
Step 38: Prepare the system for deployment to production.
-
Step 39: Run ' git commit -a -m "Update Gemfile.lock for Heroku" '
-
Step 40: Create an account on Heroku.
-
Step 41: Run the command "heroku login".
-
Step 42: Add keys to Heroku by running command "heroku keys:add".
-
Step 43: Run "heroku create".
-
Step 44: Use Git to push the master branch up to Heroku to deploy the application: $ git push heroku master
-
Step 45: Finished !!
Detailed Guide
Cloud IDE comes with pre-configured tools for Rails App Development.
, Check "Private to the people I invite".
Click on "Rails" icon (not Ruby on Rails icon).
Click Create. ,,
-v denotes the version. , This will create a new app named "hello_world".
You will notice a new directory created with the name "hello_world" in the workspace. ,, end , After "Rails.application.routes.draw do"
add a line " root 'application#hello' ".Save the changes by "Ctrl + S". ,, To do this, click on the "+" sign on the terminal window and choose "New Terminal".
Start Rails server by running the command " rails server
-b $IP
-p $PORT". , Your application should display "Hello World! ". , Git helps in version control. ,, To do this, use the commit command: git commit
-m "Initialize repository"
, Run "cat ~/.ssh/id_rsa.pub" command.
It will give you your public key.
Add your public key to Bitbucket by clicking on the avatar image in the upper right and selecting “Manage account” and then “SSH keys”.
After adding the key, click on “Create” to create a new repository.
Fill the name and click "Create Repository". , Run the commands as given in the instructions.
It will be something like below: git remote add origin [email protected]:/hello_world.git git push
-u origin
--all ,, Run bundle install with a special flag to prevent the local installation of any production gems. "bundle install
--without production"
,, Fill in the correct details with which you have created your Heroku account. ,, It creates a new subdomain just for our application, available for immediate viewing. ,, Our newly created "Hello_World" App is live on the internet.
About the Author
Isabella Hall
Experienced content creator specializing in cooking guides and tutorials.
Rate This Guide
How helpful was this guide? Click to rate: