Herokuはじめ
Railsとgitは前回のエントリでインストール済みです。
Herokuのアカウント作成
http://heroku.com/
でsignup
"heroku" gemのインストール
$ gem install heroku Successfully installed rest-client-1.6.1 Successfully installed configuration-1.2.0 Successfully installed launchy-0.3.7 Successfully installed json_pure-1.4.6 Successfully installed heroku-1.14.8 5 gems installed …
gemをインストールしたら、公開鍵を作成?するのがお勧めだそうな。
$ heroku keys:add Uploading ssh public key C:\Documents and Settings\***/.ssh/id_rsa.pub Enter your Heroku credentials. Email: hoge@hoge.com Password: Uploading ssh public key C:\Documents and Settings\***/.ssh/id_rsa.pub
あとは以下エントリを参考に…
http://hamasyou.com/archives/000348
$ rails new test_app $ cd test_app #忘れるとエラい目に $ git init $ git add . $ git commit -m "rails new test_app" $ heroku create $ heroku stack $ heroku stack:migrate bamboo-mri-1.9.2 $ git push heroku master
Rails3はじめ
WEB+DB PRESS vol.58(2010)の特集参照。
前提インストール
- ruby1.9.2
- http://rubyinstaller.org/downloads/
- Ruby 1.9.2-p0をクリック。
- splite3
- http://www.sqlite.org/download.html
- sqlitedll-3_7_3.zipをクリック
- 展開したsqlite3.dllをRuby192\binに配置
- git
- http://git-scm.com/download
- msysGitをクリック>Downloadsタブ>Git-1.7.3.1-preview20101002.exe
>ruby -v ruby 1.9.2p0 (2010-08-18) [i386-mingw32] >gem -v 1.3.7 >git --version git version 1.7.3.1.msysgit.0
railsインストール
>gem i rails Successfully installed activesupport-3.0.3 Successfully installed builder-2.1.2 …
gitによるバージョン管理
blog_app>git init Initialized empty Git repository in D:/XXX/blog_app/.git/ blog_app>git add -A warning: LF will be replaced by CRLF in .gitignore. The file will have its original line endings in your working directory. … blog_app>git commit -m "rails new blog_app" [master (root-commit) cb2bc36] rails new blog_app Committer: unknown…
scaffold
blog_app>rails g scaffold post title:string body:text Could not find gem 'sqlite3-ruby (>= 0, runtime)' in any of the gem sources lis ed in your Gemfile. Try running `bundle install`. blog_app>bundle install Fetching source index for http://rubygems.org/ Using rake (0.8.7) Using abstract (1.0.0) … Using rails (3.0.3) Installing sqlite3-ruby (1.3.2) Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed. blog_app>rails g scaffold post title:string body:text invoke active_record create db/migrate/20101204105343_create_posts.rb … invoke stylesheets create public/stylesheets/scaffold.css
データベースの作成
blog_app>rake db:migrate
(in D:/XXX/blog_app)
== CreatePosts: migrating ====================================================
create_table(:posts)
-> 0.0156s
== CreatePosts: migrated (0.0156s) ===========================================
テストの実行
blog_app>rake (in D:/XXX/blog_app) Loaded suite D:/home/bin/Ruby192/lib/ruby/1.9.1/rake/rake_test_loader Started . Finished in 2.046875 seconds. 1 tests, 1 assertions, 0 failures, 0 errors, 0 skips Test run options: --seed 61845 Loaded suite D:/home/bin/Ruby192/lib/ruby/1.9.1/rake/rake_test_loader Started ....... Finished in 3.093750 seconds. 7 tests, 10 assertions, 0 failures, 0 errors, 0 skips Test run options: --seed 3821
アプリケーションの実行
blog_app>rails s => Booting WEBrick => Rails 3.0.3 application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server [2010-12-04 20:01:18] INFO WEBrick 1.3.1 [2010-12-04 20:01:18] INFO ruby 1.9.2 (2010-08-18) [i386-mingw32] [2010-12-04 20:01:19] INFO WEBrick::HTTPServer#start: pid=4124 port=3000