When / where to initialize the client using twitter

I am new to ruby ​​on rails and trying to write a simple application that includes login and interface with Twitter API via sferik twitter gem. The documentation suggests setting up the client as follows:

client = Twitter::REST::Client.new do |config|
config.consumer_key        = Rails.application.config.twitter_key
config.consumer_secret     = Rails.application.config.twitter_secret
config.access_token        = Rails.application.config.omniauth_token
config.access_token_secret = Rails.application.config.omniauth_secret 

My question is where in my project should this be, and is it normal to repeat this block across multiple files / methods? Right now, I only have a user model and a home_controller and session_controller.

Please let me know if I need to change anything about this question or its wording, as this is my first StackOverflow question. Thank!

+4
source share
1

"" , .

access_key access_token, Twitter, .

Twitter , "" (config/initializers/twitter.rb).

0

All Articles