0

每当我尝试创建或更新我们的应用程序使用的环境时,我都会得到以下信息:

NoMethodError (undefined method `base_url' for #<HashWithIndifferentAccess:0x107162f08>):
  app/controllers/environments_controller.rb:64:in `check_base_url_for_https'
  app/controllers/environments_controller.rb:56:in `update'
  haml (3.0.22) lib/sass/plugin/rack.rb:41:in `call'
  airbrake (3.0.4) lib/airbrake/rack.rb:27:in `call'
  airbrake (3.0.4) lib/airbrake/user_informer.rb:12:in `call'
  /Users/jasonbodak/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
  /Users/jasonbodak/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
  /Users/jasonbodak/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
  /Users/jasonbodak/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/webrick/server.rb:162:in `start'
  /Users/jasonbodak/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
  /Users/jasonbodak/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/webrick/server.rb:95:in `start'
  /Users/jasonbodak/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/webrick/server.rb:92:in `each'
  /Users/jasonbodak/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/webrick/server.rb:92:in `start'
  /Users/jasonbodak/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/webrick/server.rb:23:in `start'
  /Users/jasonbodak/.rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/webrick/server.rb:82:in `start'

正如我在标题中所说,我最近升级到 Rails 2.3.11。这个错误以前从未发生过。这是我的environments_controller.rb中发生错误时正在执行的代码:

def check_base_url_for_https
  @environment = params[:environment]
  if /^https:\/\//i =~ @environment.base_url 
    @ajax_flash = "<ul class='notice'><li>The website you are trying to test is a secure site.  If you are using self-signed SSL certificates please see our <a href='http://support.janova.us'>Support Site</a> and search for SSL for important tips on how to access your site.</li></ul>"
  end
end

有谁知道为什么这段代码(特别是该行在if /^https:\/\//i =~ @environment.base_urlRails 2.3.11 中不再有效?

我想补充一点,我的 app/models/environment.rb 中的代码似乎也很合理:

def base_url 
  self[:base_url].try(:gsub, /\$/, '') 
end 

有人看到上面的代码有什么问题吗?

4

1 回答 1

0

我想通了:params[:environment]被定义为哈希。谢谢你,弗罗斯特,强迫我看到这个。因此,我将线路更改@environment = params[:environment]@environment = Environment.new(params[:environment])并且它有效。

于 2012-07-16T16:50:03.713 回答