title: Figaro Gem on Rails
body: <p>I'm struggling to set figaro up on my rails 4 app.</p>
  
  <p>I have application.yml:</p>
  
  <pre><code>GMAIL_USERNAME_CFR: aaa@gmail.com
  GMAIL_PW_PROD_CFR: bbb
  
  GMAIL_USERNAME_PROD_WELCOME: ccc@gmail.com
  GMAIL_PW_PROD_WELCOME: ddd
  </code></pre>
  
  <p>I have a production.rb file:</p>
  
  <pre><code>config.action_mailer.smtp_settings = {
      address:              'smtp.gmail.com',
      port:                 587,
      domain:               'gmail.com',
      user_name:            Figaro.env.GMAIL_USERNAME_CFR,
      password:             Figaro.env.GMAIL_PW_PROD_CFR,
      authentication:       'plain',
      enable_starttls_auto: true  }
  </code></pre>
  
  <p>In my user.rb I have 2 mailers set up. When I don't use figaro and just put the username and password directly in the production.rb file - these mailers work.  Using Figaro, I get an authentication error.</p>
  
  <p>My user.rb methods are:</p>
  
  <pre><code> def send_admin_mail
           puts "the value is:" + Figaro.env.GMAIL_USERNAME_CFR.to_s
           AdminMailer.new_user_waiting_for_approval(self).deliver
         end
  
         def send_user_welcome_mail
  
           AdminMailer.new_user_waiting_for_access(self).deliver
         end
  </code></pre>
  
  <p>You can see that I tried to figure out the problem with the puts line in the first method above. The log puts 'the value is' and then does not put the username as a string.</p>
  
  <p>My mailers are:</p>
  
  <pre><code>def new_user_waiting_for_approval(user)
      @user = user
      mail(to: "aaa@gmail.com", from: Figaro.env.GMAIL_USERNAME_CFR, 
      subject: "Registration Request #{user.first_name} #{user.last_name} &lt;#{user.email}&gt;")
    end
  
    def new_user_waiting_for_access(user)
      @user = user
      mail(to: user.email, from: "ccc@gmail.com", subject: "Welcome, #{user.first_name}")
    end
  </code></pre>
  
  <p>You can see above that I have tried to use figaro in the first mailer and the email address in the second email. Neither option works. I have also tried ENV[] instead of Figaro.env before the username and password.</p>
  
  <p>My console shows the details correctly when I convert them to strings - except they are shown between "". I assume that's of no significance.</p>
  
  <p>Can anyone see what I need to do to fix my figaro setup?</p>
  
  <p>Thank you</p>