Hello World from OSS Silicon Valley


HowToUse/RubyOnRails/4.2/Heroku/2015


  • The added line is THIS COLOR.
  • The deleted line is THIS COLOR.
#contents

*Prerequisite [#z427d905]
-Ubuntu Server installation (You can refer [[Overall/UbuntuServer]])
-Ruby On Rails installation (You can refer [[Overall/RubyOnRails]])
-Ubuntu Server 14.04 installation (You can refer [[HowToUse/UbuntuServer/14.04]])
-RVM installation (You can refer [[HowToUse/RVM/1.25]])
-Ruby On Rails installation (You can refer [[HowToUse/RubyOnRails/4.1]])
-PostgreSQL installation (You can refer [[HowToUse/PostgreSQL/9.3]])
-Ruby On Rails with PostgreSQL connection (You can refer [[HowToUse/RubyOnRails/4.2/PostgreSQL/9.3]])

*Install&Setup [#re66614c]
**Prepare Heroku's development environment [#ze65401f]
:Step.1|
Access to Heroku's web site.

#ref(CreateAccount_fig1.png,,500x266,)

:Step.2|
Login the system.

#ref(CreateAccount_fig2.png,,500x266,)

#ref(CreateAccount_fig3.png,,500x266,)

:Step.3|
Click the Ruby's icon, and you will see the instruction how to install Heroku Toolbelt.

#ref(CreateAccount_fig4.png,,500x266,)

:Step.4|
Execute the following commands.
Install bundler to your environment.

 $ gem install bundler

:Step.5|
Download Heroku Toolbelt from the link in web page.


*HowToUse [#x70f7da3]
*HowToUse [#qe563e1e]
**Create rails project [#h6e960a7]

:Step.1|
Login to Heroku server.

 $ heroku login

:Step.2|
Prepare sample project from GitHub.
Create new rails project.

 $ git clone https://github.com/heroku/ruby-getting-started.git
 $ cd ruby-getting-started
 $ rails new <project name> --database=postgresql


:Step.3|
Create new project in Heroku space.
Create new controller for welcome page.

 $ heroku create
 $ rails generate controller welcome

:Step.4|
Deploy the sample project to Heroku server.
Create welcome page.

 $ git push heroku master
 $ vi app/views/welcome/index.html.erb 

 <h2>Hello World</h2>
 <p>
 <%= Time.now %>
 </p>

:Step.5|
Launch instance.
Config routing setting

 $ heroku open
 $ vi config/routes.rb

:Step.6|
Check server log.
 root 'welcome#index'

 $ heroku logs --tail

:Step.6|
Enter Ctrl-C, and define Procfile.
Check if it can run in local environment.

 $ vi Procfile
 $ rails s

 web: bundle exec puma -C config/puma.rb

:Step.7|
Check how many dynos is launched.
Create new project in Heroku space.

 $ heroku ps
 $ heroku create


:Step.8|
Execute the bundle install
Deploy the sample project to Heroku server.

 $ bundle install
 $ git init
 $ git add .
 $ git commit -m "initial checkin"
 $ git push heroku master

Then you can access your application.

:Step.9|
Run the application locally.
#ref(CreateApps_fig1.png,,500x266,)

 $ bundle exec rake db:create db:migrate

:Step.10
Create/migrate database.
**Connect Database [#jf515d14]
:Step.1|
Migrate database

 $ rake db:create db:migrate
 $ heroku run rake db:migrate

:Step.11
Launch local instance.

 $ heroku local web

Then you can access to http://localhost:5000/

*Author [#r1ccd722]
S.Yatsuzuka