Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Based on tapajos comment, I was able to to refactor the code using initializers. First I created one to load the configuration file:

APP_CONFIG = YAML.load_file(File.expand_path('../../config.yml', __FILE__))

Then I created another initializer, like this:

superfeedr_config = {
 :host => APP_CONFIG["general"]["hostname"],
 :login => APP_CONFIG["superfeedr"]["username"],
 :password => APP_CONFIG["superfeedr"]["password"]
}
Rails.configuration.middleware.use Rack::Superfeedr, superfeedr_config do |superfeedr|
 Superfeedr = superfeedr
 superfeedr.on_notification {|notification| Article.create_from_raw_notification(notification)}
end

I also applied the logic described in this SO question to ensure the load order: How do I change the load order of initializers in Rails 3? How do I change the load order of initializers in Rails 3?.

Based on tapajos comment, I was able to to refactor the code using initializers. First I created one to load the configuration file:

APP_CONFIG = YAML.load_file(File.expand_path('../../config.yml', __FILE__))

Then I created another initializer, like this:

superfeedr_config = {
 :host => APP_CONFIG["general"]["hostname"],
 :login => APP_CONFIG["superfeedr"]["username"],
 :password => APP_CONFIG["superfeedr"]["password"]
}
Rails.configuration.middleware.use Rack::Superfeedr, superfeedr_config do |superfeedr|
 Superfeedr = superfeedr
 superfeedr.on_notification {|notification| Article.create_from_raw_notification(notification)}
end

I also applied the logic described in this SO question to ensure the load order: How do I change the load order of initializers in Rails 3?.

Based on tapajos comment, I was able to to refactor the code using initializers. First I created one to load the configuration file:

APP_CONFIG = YAML.load_file(File.expand_path('../../config.yml', __FILE__))

Then I created another initializer, like this:

superfeedr_config = {
 :host => APP_CONFIG["general"]["hostname"],
 :login => APP_CONFIG["superfeedr"]["username"],
 :password => APP_CONFIG["superfeedr"]["password"]
}
Rails.configuration.middleware.use Rack::Superfeedr, superfeedr_config do |superfeedr|
 Superfeedr = superfeedr
 superfeedr.on_notification {|notification| Article.create_from_raw_notification(notification)}
end

I also applied the logic described in this SO question to ensure the load order: How do I change the load order of initializers in Rails 3?.

Source Link
caffo
  • 31
  • 6

Based on tapajos comment, I was able to to refactor the code using initializers. First I created one to load the configuration file:

APP_CONFIG = YAML.load_file(File.expand_path('../../config.yml', __FILE__))

Then I created another initializer, like this:

superfeedr_config = {
 :host => APP_CONFIG["general"]["hostname"],
 :login => APP_CONFIG["superfeedr"]["username"],
 :password => APP_CONFIG["superfeedr"]["password"]
}
Rails.configuration.middleware.use Rack::Superfeedr, superfeedr_config do |superfeedr|
 Superfeedr = superfeedr
 superfeedr.on_notification {|notification| Article.create_from_raw_notification(notification)}
end

I also applied the logic described in this SO question to ensure the load order: How do I change the load order of initializers in Rails 3?.

lang-rb

AltStyle によって変換されたページ (->オリジナル) /