Railsメモ その5

Twitterのgemで画像を取得する。

Route 477 - Ruby Twitter Gem簡易リファレンスModule: Twitter::Client::Users — Documentation for twitter (2.1.0)では、

Twitter.profile_image() 自分のプロファイル画像

って書いてあるけど、うまくいかない。

Twitter.user.profile_image_url() 

でイメージ画像のURLを取得することが出来る。

Twitter.user.methods 

でメソッド一覧を検索したらあったのでそれを使った。

とりあえずこのURLを保存しておけばいいかなー。

SQLiteカラム名一覧を取得する

migrateができてるか心配で、カラム一覧を取得するSQLを探した。

Linux 作業メモ -sqliteでカラム一覧を取得する方法

PRAGMA table_info(users);

#カラムって単語か思い出せなくて非常に遠回りをしました…

TweetStreamをrails

twitter - Tweetstream and Rails - can't get any response - Stack Overflow

You will need to run TweetStream side by side with Rails as a daemon process collecting the tweets, storing them on a DB and Rails will access that same DB.

Use Rails Runner (http://guides.rubyonrails.org/command_line.html#rails-runner) to run your TweetStream daemon on the context of Rails, this should give you access to the models.

No it won't. For example if you need to host this in, let's say Heroku, you will need to use a Procfile and run it with a worker side by side to rails: web: bundle exec rails server thin -p $PORT -e $RACK_ENV \n stream: bundle exec rails runner streaming.rb When using a Procfile, you could launch both locally by using foreman (foreman start) –

とりあえずここに書いてあるように、Rails runner でやってみたらできたっぽい

Rails3 runnerを利用してでバッチプログラムを実行するサンプル - hrendohの日記

確証はない。