2010-09-16
HerokuでRuby1.9とRails3を使って1時間でツイッターサービスを作ろう!
HerokuでRuby1.9とRails3を使う - それはBooksで1時間でツイッターサービスを作ろう! | KRAY Incをやってみた。試行錯誤しながらだったので1時間以上かかったし、この通りにやって1時間でできるかどうかは知らない。
まずはHerokuでRuby1.9とRails3を使う - それはBooksを参考にHerokuを設定する。この記事だとローカルにRails環境を構築するのところで
rails heroku-demo
ってあるけどそれじゃ作れなくて
rails new heroku-demo
のようにnewが必要だった。それとbamboo-mri-1.9.2が使えたのでそれ選んだ。他は記事の通り。
続きは1時間でツイッターサービスを作ろう! | KRAY Incを見ながら。Rails3だと結構違う。
gem 'twitter-auth', :require => 'twitter_auth/engine', :git => 'git://github.com/rokudenashi/twitter-auth.git', :branch => 'rails_3'
を追加して、bundle installでインストールする。
script/generateはなくなっているのでrails generateを使う。
config/routes.rbは、get "messages/index"というのが追加されているのでそれを消して
resources :messages, :only => [:index, :create]
root :to => 'messages#index'
を追加する。
app/controllers/messages_controller.rbはファイルの最初に
#-*- coding: utf-8 -*-
を追加する。あとこれはRails3関係ないけど
current_user.twitter.post('/statuses/update.json', :status => "偉大なるHelloWorld")
〜〜
rescue
〜〜
end
.gemsファイルはGemfileに変わったので必要ないみたい。
こんな感じでできたのがこちら→これはろくでもない!
参考なんちゃら
- 129 http://reader.livedoor.com/reader/
- 106 http://b.hatena.ne.jp/hotentry
- 105 http://b.hatena.ne.jp/hotentry/it
- 64 http://news.atode.cc/
- 54 http://twitter.com/u_thule
- 43 http://d.hatena.ne.jp/
- 42 http://twitter.com/
- 31 http://news.atode.cc/?d=20100919
- 28 http://www.google.com/reader/view/
- 26 http://www.google.co.jp/reader/view/
