未初始化的常量 Rails::Initializer (NameError)

发布于 2024-12-09 13:54:18 字数 1219 浏览 1 评论 0 原文

environment.rb:7: uninitialized constant Rails::Initializer (NameError)
    from /usr/lib/ruby/gems/1.8/gems/railties-3.1.0/lib/rails/application.rb:78:in `require_environment!'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.1.0/lib/rails/commands.rb:39
    from script/rails:6:in `require'
    from script/rails:6

我遇到了前面的错误,我正在尝试按照此处的 PDF 将 salesforce 与 Rails 应用程序集成: http://blogs.developerforce.com/developer-relations/2011/02/a-brief-history-of-ruby-rails-with-the-forcecom-platform.html

我已完成所需说明,但需要编辑 environment.rb 这是我当前的版本:

# Load the rails application
require File.expand_path('../application', __FILE__)

# Initialize the rails application
Newsletter::Application.initialize!

Rails::Initializer.run do |config|
  config.gem "asf-soap-adapter", :lib => "activerecord-activesalesforce-adapter"
  config.gem "asf-soap-adapter", :lib => 'asf-soap-adapter'
  config.database_configuration_file = File.join(RAILS_ROOT, 'config','salesforce.yml')
  config.time_zone = 'UTC'
end 
environment.rb:7: uninitialized constant Rails::Initializer (NameError)
    from /usr/lib/ruby/gems/1.8/gems/railties-3.1.0/lib/rails/application.rb:78:in `require_environment!'
    from /usr/lib/ruby/gems/1.8/gems/railties-3.1.0/lib/rails/commands.rb:39
    from script/rails:6:in `require'
    from script/rails:6

I'm getting the preceding error, I'm trying to integrate salesforce with a rails app following the PDF here: http://blogs.developerforce.com/developer-relations/2011/02/a-brief-history-of-ruby-rails-with-the-forcecom-platform.html

I have made the instructions required, however it is required to edit the environment.rb
Here is my current version:

# Load the rails application
require File.expand_path('../application', __FILE__)

# Initialize the rails application
Newsletter::Application.initialize!

Rails::Initializer.run do |config|
  config.gem "asf-soap-adapter", :lib => "activerecord-activesalesforce-adapter"
  config.gem "asf-soap-adapter", :lib => 'asf-soap-adapter'
  config.database_configuration_file = File.join(RAILS_ROOT, 'config','salesforce.yml')
  config.time_zone = 'UTC'
end 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

深海蓝天 2024-12-16 13:54:18

根据您的标签,我假设您正在 Rails 3 应用程序中工作,您遇到的问题是您拥有的environment.rb 是 Rails 2 特定的。在 Rails 3 中,您应该在 Gemfile 中指定 gem,并从environment.rb 中删除 Rails::Initializer。

将其添加到您的 Gemfile 中:

gem 'asf-soap-adapter', :require =>'activerecord-activesalesforce-adapter'

这里有一些关于从 Rails 2 升级的注释 -> Rails 3。

http:// rails3.community-tracker.com/permalinks/5/notes-from-the-field-upgrading-to-rails-3

I assume based on your tag that you are working in a Rails 3 app, the issue you have is that the environment.rb you have is Rails 2 specific. In Rails 3 you should be specifying your gems in your Gemfile, and removing the Rails::Initializer from your environment.rb.

Add this to your Gemfile:

gem 'asf-soap-adapter', :require =>'activerecord-activesalesforce-adapter'

There are some notes here on the upgrade from Rails 2 -> Rails 3.

http://rails3.community-tracker.com/permalinks/5/notes-from-the-field-upgrading-to-rails-3

灯角 2024-12-16 13:54:18

我使用新的 Gem 'databasedotcom' 来达到同样的目的,效果非常好
http://richardvanhook.github.com/databasedotcom-guide/#create_a_databasecom_account

I used the new Gem 'databasedotcom' for the same purpose which works perfectly
http://richardvanhook.github.com/databasedotcom-guide/#create_a_databasecom_account

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文