Skip to content

Instantly share code, notes, and snippets.

@potatosalad
Created August 10, 2012 17:08
Show Gist options
  • Select an option

  • Save potatosalad/3315722 to your computer and use it in GitHub Desktop.

Select an option

Save potatosalad/3315722 to your computer and use it in GitHub Desktop.
require 'stalker'
stalker_config_file = File.join(Rails.root, 'config', 'stalker.yml')
if File.file?(stalker_config_file)
environment = defined?(Rails) && Rails.respond_to?(:env) ? Rails.env : ENV["RACK_ENV"]
settings = YAML.load(ERB.new(File.new(stalker_config_file).read).result)[environment]
if settings.present?
begin
Stalker.connect(settings['beanstalk_url'])
rescue Beanstalk::NotConnected => e
Stalker.class_variable_set(:@@url, nil) if Stalker.class_variable_defined?(:@@url)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment