IT Staff

Blog về chuyên ngành IT

Deploy Ruby App On Heroku

leave a comment »

My ruby app name myapp1, so I want to deploy it on heroku server, and I’ve already my heroku account: rrrubbby.
My next step is installing and deploying this app on heroku servver.

1. First, install heroku on ubuntu:

$ sudo wget -qO- | sh

If you’ve met any problems on this step, let update system:

$ sudo apt-get update

Fetched 3,115kB in 1min 10s (44.4kB/s)

Selecting previously deselected package libruby1.9.1.

(Reading database … 277508 files and directories currently installed.)

Unpacking libruby1.9.1 (from …/libruby1.9.1_1.9.1.378-1_i386.deb) …

Selecting previously deselected package ruby1.9.1.

Unpacking ruby1.9.1 (from …/ruby1.9.1_1.9.1.378-1_i386.deb) …

Selecting previously deselected package foreman.

Unpacking foreman (from …/foreman_0.44.0_all.deb) …

Selecting previously deselected package libopenssl-ruby1.9.1.

Unpacking libopenssl-ruby1.9.1 (from …/libopenssl-ruby1.9.1_1.9.1.378-1_i386.deb) …

Selecting previously deselected package libreadline-ruby1.9.1.

Unpacking libreadline-ruby1.9.1 (from …/libreadline-ruby1.9.1_1.9.1.378-1_i386.deb) …

Selecting previously deselected package heroku.

Unpacking heroku (from …/heroku_2.28.12_all.deb) …

Selecting previously deselected package heroku-toolbelt.

Unpacking heroku-toolbelt (from …/heroku-toolbelt_2.28.12_all.deb) …

Processing triggers for man-db …

Setting up libruby1.9.1 ( …

Setting up ruby1.9.1 ( …

Setting up foreman (0.44.0) …

Setting up libopenssl-ruby1.9.1 ( …

Setting up libreadline-ruby1.9.1 ( …

Setting up heroku (2.28.12) …

Setting up heroku-toolbelt (2.28.12) …

Processing triggers for libc-bin …

ldconfig deferred processing now taking place

Okay, now login in heroku.

2. Login heroku

$ heroku login
Enter your Heroku credentials.


Password (typing will be hidden):

Could not find an existing public key.

Would you like to generate one? [Yn] y

Generating new SSH public key.

Uploading SSH public key /home/rrrubbby/.ssh/… done

Authentication successful.

Change to your app’s folder:

$ cd ~/Code/Ruby/myapp1

Using create command of heroku:

$ ~/Code/Ruby/myapp1$ heroku create

Creating high-mountain-3417… done, stack is cedar |

Git remote heroku added

Your app will be added on heroku with domain’s name is and repository name is high-mountain-3417.git. You can see the detail tutorial at:

Next, call git init for our repository.

~/Code/Ruby/myapp1$ git init

Reinitialized existing Git repository in /home/rrrubbby/Code/Ruby/myapp1/.git/

Add all items to git.

~/Code/Ruby/myapp1$ git add .

Then, commit all actions on git with the description.

~/Code/Ruby/myapp1$ git commit -m “init”

[master 108ce31] init

106 files changed, 2075 insertions(+), 1 deletions(-)

create mode 100644 app/assets/javascripts/

create mode 100644 app/assets/javascripts/defaults.js

create mode 100644 app/assets/javascripts/

create mode 100644 app/assets/javascripts/

create mode 100644 app/assets/javascripts/

create mode 100644 app/assets/stylesheets/application.css.scss

create mode 100644 app/assets/stylesheets/carts.css.scss

create mode 100644 app/assets/stylesheets/line_items.css.scss

create mode 100644 app/assets/stylesheets/orders.css.scss

create mode 100644 app/assets/stylesheets/store.css.scss

create mode 100644 app/controllers/carts_controller.rb

create mode 100644 app/controllers/line_items_controller.rb

create mode 100644 app/controllers/orders_controller.rb

create mode 100644 app/controllers/store_controller.rb

create mode 100644 app/helpers/carts_helper.rb

create mode 100644 app/helpers/line_items_helper.rb

create mode 100644 app/helpers/orders_helper.rb

create mode 100644 app/helpers/store_helper.rb

create mode 100644 app/models/cart.rb

create mode 100644 app/models/line_item.rb

create mode 100644 app/models/order.rb

create mode 100644 app/views/carts/_cart.html.erb

create mode 100644 app/views/carts/_form.html.erb

create mode 100644 app/views/carts/edit.html.erb

create mode 100644 app/views/carts/index.html.erb

create mode 100644 app/views/carts/new.html.erb

create mode 100644 app/views/carts/show.html.erb

create mode 100644 app/views/line_items/_form.html.erb

create mode 100644 app/views/line_items/_line_item.html.erb

create mode 100644 app/views/line_items/create.js.erb

create mode 100644 app/views/line_items/edit.html.erb

create mode 100644 app/views/line_items/index.html.erb

create mode 100644 app/views/line_items/new.html.erb

create mode 100644 app/views/line_items/show.html.erb

create mode 100644 app/views/orders/_form.html.erb

create mode 100644 app/views/orders/edit.html.erb

create mode 100644 app/views/orders/index.html.erb

create mode 100644 app/views/orders/new.html.erb

create mode 100644 app/views/orders/show.html.erb

create mode 100644 app/views/store/index.html.erb

create mode 100644 db/migrate/20120701222746_create_carts.rb

create mode 100644 db/migrate/20120702145709_create_line_items.rb

create mode 100644 db/migrate/20120703141526_add_quantity_to_line_items.rb

create mode 100644 db/migrate/20120703160732_combine_items_in_cart.rb

create mode 100644 db/migrate/20120703175830_add_price_to_line_items.rb

create mode 100644 db/migrate/20120703180538_copy_product_price_into_line_item.rb

create mode 100644 db/migrate/20120709181916_create_orders.rb

create mode 100644 db/migrate/20120709182208_add_order_id_to_line_item.rb

create mode 100644 ls

create mode 100644 public/images/auto.jpg

create mode 100644 public/images/cs.jpg

create mode 100644 public/images/debug.jpg

create mode 100644 public/images/logo.png

create mode 100755 public/images/product_imgs/1.jpg

create mode 100755 public/images/product_imgs/10.jpg

create mode 100755 public/images/product_imgs/11.jpg

create mode 100755 public/images/product_imgs/12.jpg

create mode 100755 public/images/product_imgs/13.jpg

create mode 100755 public/images/product_imgs/14.jpg

create mode 100755 public/images/product_imgs/15.jpg

create mode 100755 public/images/product_imgs/2.jpg

create mode 100755 public/images/product_imgs/3.jpg

create mode 100755 public/images/product_imgs/4.jpg

create mode 100755 public/images/product_imgs/5.jpg

create mode 100755 public/images/product_imgs/6.jpg

create mode 100755 public/images/product_imgs/7.jpg

create mode 100755 public/images/product_imgs/8.jpg

create mode 100755 public/images/product_imgs/9.jpg

create mode 100755 public/images/product_imgs/home.jpg

create mode 100644 public/images/rail.png

create mode 100644 public/images/rtp.jpg

create mode 100644 public/images/ruby.jpg

create mode 100644 public/images/svn.jpg

create mode 100644 public/images/utc.jpg

create mode 100644 public/images/wd4d.jpg

create mode 100644 public/index_bak.html

create mode 100644 test/fixtures/carts.yml

create mode 100644 test/fixtures/line_items.yml

create mode 100644 test/fixtures/orders.yml

create mode 100644 test/functional/carts_controller_test.rb

create mode 100644 test/functional/line_items_controller_test.rb

create mode 100644 test/functional/orders_controller_test.rb

create mode 100644 test/functional/store_controller_test.rb

create mode 100644 test/unit/cart_test.rb

create mode 100644 test/unit/helpers/carts_helper_test.rb

create mode 100644 test/unit/helpers/line_items_helper_test.rb

create mode 100644 test/unit/helpers/orders_helper_test.rb

create mode 100644 test/unit/helpers/store_helper_test.rb

create mode 100644 test/unit/line_item_test.rb

create mode 100644 test/unit/order_test.rb

create mode 100644 vendor/assets/images/ui-bg_flat_0_aaaaaa_40x100.png

create mode 100644 vendor/assets/images/ui-bg_flat_75_ffffff_40x100.png

create mode 100644 vendor/assets/images/ui-bg_glass_55_fbf9ee_1x400.png

create mode 100644 vendor/assets/images/ui-bg_glass_65_ffffff_1x400.png

create mode 100644 vendor/assets/images/ui-bg_glass_75_dadada_1x400.png

create mode 100644 vendor/assets/images/ui-bg_glass_75_e6e6e6_1x400.png

create mode 100644 vendor/assets/images/ui-bg_glass_95_fef1ec_1x400.png

create mode 100644 vendor/assets/images/ui-bg_highlight-soft_75_cccccc_1x100.png

create mode 100644 vendor/assets/images/ui-icons_222222_256x240.png

create mode 100644 vendor/assets/images/ui-icons_2e83ff_256x240.png

create mode 100644 vendor/assets/images/ui-icons_454545_256x240.png

create mode 100644 vendor/assets/images/ui-icons_888888_256x240.png

create mode 100644 vendor/assets/images/ui-icons_cd0a0a_256x240.png

create mode 100644 vendor/assets/javascripts/jquery-1.7.2.min.js

create mode 100644 vendor/assets/javascripts/jquery-ui-1.8.21.custom.min.js

create mode 100644 vendor/assets/stylesheets/jquery-ui-1.8.21.custom.css

Now, push your app to heroku master.

~/Code/Ruby/myapp1$ git push heroku master

Counting objects: 301, done.

Delta compression using up to 2 threads.

Compressing objects: 100% (279/279), done.

Writing objects: 100% (301/301), 468.98 KiB | 60 KiB/s, done.

Total 301 (delta 71), reused 0 (delta 0)

—–> Heroku receiving push

—–> Ruby/Rails app detected

—–> Installing dependencies using Bundler version 1.2.0.pre

Running: bundle install –without development:test –path vendor/bundle –binstubs bin/ –deployment

Fetching gem metadata from…….

Installing rake (

Installing i18n (0.6.0)

Installing multi_json (1.3.5)

Installing activesupport (3.2.3)

Installing builder (3.0.0)

Installing activemodel (3.2.3)

Installing erubis (2.7.0)

Installing journey (1.0.3)

Installing rack (1.4.1)

Installing rack-cache (1.2)

Installing rack-test (0.6.1)

Installing hike (1.2.1)

Installing tilt (1.3.3)

Installing sprockets (2.1.3)

Installing actionpack (3.2.3)

Installing mime-types (1.18)

Installing polyglot (0.3.3)

Installing treetop (1.4.10)

Installing mail (2.4.4)

Installing actionmailer (3.2.3)

Installing arel (3.0.2)

Installing tzinfo (0.3.33)

Installing activerecord (3.2.3)

Installing activeresource (3.2.3)

Installing coffee-script-source (1.3.3)

Installing execjs (1.4.0)

Installing coffee-script (2.2.0)

Installing rack-ssl (1.3.2)

Installing json (1.7.3) with native extensions

Installing rdoc (3.12)

Installing thor (0.14.6)

Installing railties (3.2.3)

Installing coffee-rails (3.2.2)

Installing jquery-rails (2.0.2)

Installing pg (0.14.0) with native extensions

Using bundler (1.2.0.pre)

Installing rails (3.2.3)

Installing sass (3.1.19)

Installing sass-rails (3.2.5)

Installing uglifier (1.2.4)

Your bundle is complete! It was installed into ./vendor/bundle

Post-install message from rdoc:

Depending on your version of ruby, you may need to install ruby rdoc/ri data:

<= 1.8.6 : unsupported

= 1.8.7 : gem install rdoc-data; rdoc-data –install

= 1.9.1 : gem install rdoc-data; rdoc-data –install

>= 1.9.2 : nothing to do! Yay!

Cleaning up the bundler cache.

—–> Writing config/database.yml to read from DATABASE_URL

—–> Preparing app for Rails asset pipeline

Running: rake assets:precompile

rake aborted!

Unexpected token: operator (=) (line: 21601, col: 1, pos: 646816)


at new JS_Parse_Error (/tmp/execjs20120712-1010-mz1h0x.js:3096:22)

at js_error (/tmp/execjs20120712-1010-mz1h0x.js:3104:15)

at croak (/tmp/execjs20120712-1010-mz1h0x.js:3557:17)

at token_error (/tmp/execjs20120712-1010-mz1h0x.js:3564:17)

at unexpected (/tmp/execjs20120712-1010-mz1h0x.js:3570:17)

at /tmp/execjs20120712-1010-mz1h0x.js:3943:17

at maybe_unary (/tmp/execjs20120712-1010-mz1h0x.js:4028:27)

at expr_ops (/tmp/execjs20120712-1010-mz1h0x.js:4055:32)

at maybe_conditional (/tmp/execjs20120712-1010-mz1h0x.js:4059:28)

at maybe_assign (/tmp/execjs20120712-1010-mz1h0x.js:4083:28)

(in /tmp/build_dtuzyrf3ifm8/app/assets/javascripts/application.js)

Tasks: TOP => assets:precompile:primary

(See full trace by running task with –trace)

Precompiling assets failed, enabling runtime asset compilation

Injecting rails31_enable_runtime_asset_compilation

Please see this article for troubleshooting help:

—–> Rails plugin injection

Injecting rails_log_stdout

Injecting rails3_serve_static_assets

—–> Discovering process types

Procfile declares types      -> (none)

Default types for Ruby/Rails -> console, rake, web, worker

—–> Compiled slug size is 10.0MB

—–> Launching… done, v4 deployed to Heroku


* [new branch]      master -> master

If you have any problems on this step, please see the detail resolutions at:

Okay, that’s all, but there are many things to do after you’ve deployed on heroku. But don’t worry, now you can go to your app’s domain and enjoyed.

Any comments to share your experiences is WELCOME!
Thanks for your attending and see you in my next post🙂

Written by Xavier

Tháng Tám 3, 2013 lúc 9:53 sáng

Posted in Staff

Gửi phản hồi

Mời bạn điền thông tin vào ô dưới đây hoặc kích vào một biểu tượng để đăng nhập: Logo

Bạn đang bình luận bằng tài khoản Log Out / Thay đổi )

Twitter picture

Bạn đang bình luận bằng tài khoản Twitter Log Out / Thay đổi )

Facebook photo

Bạn đang bình luận bằng tài khoản Facebook Log Out / Thay đổi )

Google+ photo

Bạn đang bình luận bằng tài khoản Google+ Log Out / Thay đổi )

Connecting to %s

%d bloggers like this: