title: How can I send tweets to my Twitter account?
body: <p>Every time the user post a comments, I want it to send the same comment to my Twitter automatically.</p>
  
  <p>First of all, I have it already done with Twitter developer settings.</p>
  
  <p>So I made a test action in my App to make it send a tweet to my Twitter account.
  However, it says this error</p>
  
  <pre><code>NoMethodError (undefined method `[]' for nil:NilClass):
  app/controllers/top_controller.rb:173:in `test_action'
  </code></pre>
  
  <p>How can I solve this? These are my codes</p>
  
  <p><strong>gems related that are already bundled</strong> (I'm on rails 3.2.11) </p>
  
  <pre><code>gem 'omniauth-twitter'
  gem 'twitter'
  gem 'figaro'
  </code></pre>
  
  <p><strong>config/initializers/omniauth.rb</strong></p>
  
  <pre><code>Rails.application.config.middleware.use OmniAuth::Builder do
    provider :twitter, ENV['TWITTER_KEY'], ENV['TWITTER_SECRET']
      Twitter.configure do |config|
          config.consumer_key = ENV["TWITTER_KEY"]
          config.consumer_secret = ENV["TWITTER_SECRET"]
      end
  end
  </code></pre>
  
  <p><strong>config/application.yml</strong></p>
  
  <pre><code>TWITTER_KEY: 6TeBX6HkeHzMXesgc
  TWITTER_SECRET: JyfOndg8xHcM81KEpgmBT7h2vFJJujMP14YTdt6ruvLbsQk
  </code></pre>
  
  <p><strong>test_action</strong></p>
  
  <pre><code>def test_action  
      @twitter = Twitter::Client.new(oauth_token: request.env["omniauth.auth"][:credentials][:token], oauth_token_secret: request.env["omniauth.auth"][:credentials][:secret])
      @twitter.update("Your message")
      flash[:notice] = "Successfully tweeted on your account."
      redirect_to root_path
      return 
  end
  </code></pre>