Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7997455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:58:08+00:00 2026-06-04T14:58:08+00:00

I have been following the solution provided in a previous question: Accessing config from

  • 0

I have been following the solution provided in a previous question:

Accessing config from application.rb in Controller (Rails 3)

but applying it for Facebook settings first.

I created the facebook config file first:

#lib/facebook_config.rb
module FacebookConfig
  def self.config
    @@config ||= {}
  end

  def self.config=(hash)
    @@config = hash
  end

end

and defined my YAML file then initialised it.

#config/facebook.yml
development:
  app_id = "id"
  app_secret = "secret"

test:
  app_id = "id"
  app_secret = "secret"

production:
  app_id = "id"
  app_secret = "secret"

and

#config/intializers/01.facebook_config.rb
require './lib/facebook_config'

FacebookConfig.config = YAML.load_file("config/facebook.yml")[Rails.env]

and defining the omniauth config as such:

#config/initializers/omniauth.rb
Rails.application.config.middleware.use OmniAuth::Builder do
  # The following is for facebook
  provider :facebook, FacebookConfig.config[:app_id], FacebookConfig.config[:app_secret], {:scope => 'email, read_stream, read_friendlists, friends_likes, friends_status, offline_access'}
end

however when I am testing in development mode I get the following error when starting up the webrick server:

config/initializers/omniauth.rb:3:in `[]’: can’t convert Symbol into Integer (TypeError)

I thought when accessing the config file it should be a String and not a Symbol?

Thanks for any tips.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T14:58:09+00:00Added an answer on June 4, 2026 at 2:58 pm

    Possible reason could be because of your facebook.yml file formatting.

    You can read about Yaml here: http://en.wikipedia.org/wiki/YAML

    Edited

    I have tested your code in dummy app – same error, because, YAML file you have currently, will return string.

    1.9.3p0 :014 > YAML.load_file("config/facebook.yml")[Rails.env]
     => "app_id = \"id\" app_secret = \"secret\""
    

    So you can not access by symbol, because Ruby thinks that you are passing Numeric Index value for String.

    Update your facebook.yml to this one (set your variables):

    #config/facebook.yml
    development:
      app_id: id
      app_secret: secret
    
    test:
      app_id: id
      app_secret: secret
    
    production:
      app_id: id
      app_secret: secret
    

    After facebook.yml update, as result you will get hash:

    YAML.load_file("config/facebook.yml")[Rails.env]
     => {"app_id"=>"id", "app_secret"=>"secret"}
    

    Symbolize your config hash keys:

      def self.config=(hash)
        @@config = hash
        @@config.symbolize_keys!
      end
    

    And it will work!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been following the validation for Entry boxes from here . The code
I have been following the affableBean tutorial from the NetBeans site located here .
I'm new to NHibernate... I have been following this NHibernate Tutorial from Gabriel Schenker
I am working on my first login script. I have been following examples from
I've searched everywhere but I can't seem to find a solution. I have been
So using the advice found in my previous ' question ', I have been
I have been following the new Steve Sanderson MVC3 framework book from Apress and
I have been following the usage of JavaScript for the past few years, and
I have been following the following post on using multiple ItemTemplates in a ListView
I have been following mozilla developer network's docs and created a transition for my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.