1

I have a RoR website at domain1.com that uses a facebook application linked to that domain.

I want to make domain2.com to point to the same server as domain1.com, so domain1.com/foo is equivalent to domain2.com/foo.

Obviously (I think) I need to make a second facebook application, because the one linked to domain1.com won't work if they visit the site under domain2.com.

However, I don't know how to tell facebooker2, in its facebooker.yml, to use one application if the request comes from one host or a different app if it comes from the other.

Is there any way to do this, or do something that achieves the same result?

B_.
  • 2,164
  • 2
  • 17
  • 20

1 Answers1

1

Facebooker2 doesn't have built-in support for this, but you can make it support it!

You'll need to override some of the functionality in this file:

facebooker2/lib/facebooker2.rb

Specifically this method:

def self.load_facebooker_yaml
  config = YAML.load(ERB.new(File.read(File.join(::Rails.root,"config","facebooker.yml"))).result)[::Rails.env]
  raise NotConfigured.new("Unable to load configuration for #{::Rails.env} from facebooker.yml. Is it set up?") if config.nil?
  self.configuration = config.with_indifferent_access
end

Change the first line to say:

config = YAML.load(ERB.new(File.read(File.join(::Rails.root,"config","facebooker.yml"))).result)[::Rails.env][::request.domain]

Then add a new level to your facebooker.yml file, something like this:

production:
  domain1.com:
    app_id: ####
    secret: #####
    aki_key: #####
  domain2.com
    app_id: ####
    secret: #####
    aki_key: #####
development:
  localhost:
    app_id: ####
    secret: #####
    aki_key: #####

Let me know how that goes.

Marshall Æon
  • 407
  • 1
  • 5
  • 18
  • Mind you, you shouldn't edit the plugin directly so you can upgrade it later. You should create your own lib file. – Marshall Æon Jan 16 '11 at 22:59
  • I was waiting to accept this answer until after I tried it but it looks like I won't be implementing multiple applications for a while now. Even so, it looks like a solid answer so I'll accept it untested. Thanks – B_. Feb 15 '11 at 19:32