準備
Railsプロジェクトをgitで管理するまでやる。
まずRailsプロジェクトを作成今回はsfmailerという名前のプロジェクトにする
$ rails -v Rails 3.2.3 $ rails new sfmailer
gitで管理するようにして最初のコミットをする
$ cd sfmailer $ git init Initialized empty Git repository in /home/toyoshi/projects/sfmailer/.git/ $ git add . $ git commit -m "first commit"
githubを使う
githubにリポジトリを作り、pushできるようにするまで。
リポジトリを作ります
名前を適当に決めて完了
これでgithubにリポジトリができたので、さっき作ったローカルのファイル郡をpushしてみます
$ git remote add origin git@github.com:toyoshi/form_mailer_generator.git $ git push -u origin master Counting objects: 63, done. Delta compression using up to 2 threads. Compressing objects: 100% (49/49), done. Writing objects: 100% (63/63), 25.96 KiB, done. Total 63 (delta 2), reused 0 (delta 0) To git@github.com:toyoshi/form_mailer_generator.git * [new branch] master -> master Branch master set up to track remote branch master from origin.
ファイルが追加されて無事コミットされたようです
herokuの準備
herokuのgemをインストールするのでGemfileを編集してbundle install
gem 'heroku', :group => [:development]
するとherokuコマンドが使えるようになるのでherokuにアプリを登録
$ heroku create Creating severe-leaf-5323..................... done, stack is bamboo-mri-1.9.2 http://severe-leaf-5323.heroku.com/ | git@heroku.com:severe-leaf-5323.git Git remote heroku added
http://severe-leaf-5323.heroku.com/にアクセスして確認してみます
さらに.git/configをみてみると"heroku"というリモートリポジトリが登録されています
$ cat .git/config [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] url = git@github.com:toyoshi/form_mailer_generator.git fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = origin merge = refs/heads/master [remote "heroku"] url = git@heroku.com:severe-leaf-5323.git fetch = +refs/heads/*:refs/remotes/heroku/*
さっそくpushしてみましょう
$ git push heroku master Counting objects: 63, done. Delta compression using up to 2 threads. Compressing objects: 100% (49/49), done. Writing objects: 100% (63/63), 25.96 KiB, done. Total 63 (delta 2), reused 0 (delta 0) -----> Heroku receiving push -----> Ruby/Rails app detected -----> Detected Rails is not set to serve static_assets Installing rails3_serve_static_assets... done -----> Configure Rails 3 to disable x-sendfile Installing rails3_disable_x_sendfile... done -----> Configure Rails to log to stdout Installing rails_log_stdout... done -----> Gemfile detected, running Bundler version 1.0.7 Unresolved dependencies detected; Installing... Using --without development:test Fetching source index for https://rubygems.org/ Installing rake (0.9.2.2) Installing i18n (0.6.0) Installing multi_json (1.2.0) 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.2) 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.32) Installing activerecord (3.2.3) Installing activeresource (3.2.3) Installing coffee-script-source (1.2.0) Installing execjs (1.3.0) Installing coffee-script (2.2.0) Installing rack-ssl (1.3.2) Installing json (1.6.6) 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.1) Installing libv8 (3.3.10.4) Using bundler (1.0.7) Installing rails (3.2.3) Installing sass (3.1.15) Installing sass-rails (3.2.5) Installing sqlite3 (1.3.5) with native extensions Installing therubyracer (0.10.0) with native extensions Installing uglifier (1.2.4) Your bundle is complete! It was installed into ./.bundle/gems/ -----> Compiled slug size is 10.5MB -----> Launching... done, v3 http://severe-leaf-5323.heroku.com deployed to Heroku To git@heroku.com:severe-leaf-5323.git * [new branch] master -> master
無事にアプリケーションが動いていることを確認して完了です。
http://severe-leaf-5323.heroku.com/
おまけ
hamlとrspecを最初からいれておく
gem 'haml-rails' group :test, :development do gem "rspec-rails", "~> 2.6" end