A simple tutorial on how to work with Rails and the twitter
gem.
-
Add
twitter
anddotenv-rails
to yourGemfile
andbundle
-
Add
.env
to your.gitignore
-
Create a
.env
file to house your Twitter keys. There is a.env_example
file to show the basic structure -
Add the
twitter.rb
file 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
TweetsController
and add anindex
action -
Update your
routes.rb
-
Create a simple
tweets/index.html.erb
view