A simple tutorial on how to work with Rails and the twitter gem.
-
Add
twitteranddotenv-railsto yourGemfileandbundle -
Add
.envto your.gitignore -
Create a
.envfile to house your Twitter keys. There is a.env_examplefile to show the basic structure -
Add the
twitter.rbfile toconfig/initializers. This is your basic config setup for your Twitter client. Note, I'm not wild about using a global variable here. It might be worth looking into alternative ways to set this up. -
Generate a
TweetsControllerand add anindexaction -
Update your
routes.rb -
Create a simple
tweets/index.html.erbview