0

Rails 和 Ruby on Rails 的新手,

文件 /host_share/my_application/config/initializers/countries.rb 中的代码

Carmen.priority_countries = %w(US CA MX)
Carmen.excluded_countries = ["AC", "AF", "AX", "AL", "DZ", "AS", "AD", "AO", "AI", "AQ", "AG", "AR", "AM", "AW", "AU", 
                               "AZ", "BS", "BH", "BD", "BB", "BY", "BZ", "BJ", "BL", "BM", "BT", "BO", "BA", "BW", "BV", 
                               "BR", "IO", "BN", "BG", "BF", "BI", "BQ", "KH", "CM", "CV", "KY", "CF", "TD", "CL", "CN", 
                               "CX", "CC", "CO", "KM", "CG", "CD", "CK", "CR", "CI", "HR", "CU", "CW", "DJ", 
                               "DM", "DO", "EC", "EG", "SV", "GQ", "ER", "EE", "ET",  "FO", "FJ", "GF", 
                               "PF", "TF", "GA", "GM", "GE", "GH", "GI", "GD", "GP", "GU", "GT", "GG", 
                               "GN", "GW", "GY", "HT", "HM", "VA", "HN", "HK", "HU", "IN", "ID", "IR", "IQ", 
                               "JM", "JP", "JE", "JO", "KZ", "KE", "KI", "KP", "KR", "KV", "KW", "KG", 
                               "LA", "LV", "LB", "LS", "LR", "LY", "LI", "LT", "MO", "MK", "MG", "MW", "MY", "MV", 
                               "ML", "MT", "MH", "MQ", "MR", "MU", "YT", "FM", "MD", "MN", "MF", "ME", "MA", 
                               "MZ", "MM", "NA", "NR", "NP", "AN", "NC", "NZ", "NI", "NE", "NG", "NU", "NF", "MP", 
                               "NO", "OM", "PK", "PW", "PS", "PA", "PG", "PY", "PE", "PH", "PN", "QA", 
                               "RE", "RO", "RU", "RW", "SH", "KN", "LC", "PM", "VC", "WS", "SM", "ST", "SA", "SN", "RS", 
                               "SC", "SL", "SG", "SK", "SI", "SB", "SO", "ZA", "GS", "LK", "SD", "SR", "SJ", "SZ", 
                               "SX", "SY", "TW", "TJ", "TZ", "TH", "TL", "TG", "TK", "TO", "TT", "TN", "TR", "TM", 
                               "TC", "TV", "UG", "UA", "AE", "UM", "UY", "UZ", "VU", "VE", "VN", 
                               "WF", "EH", "YE", "ZM", "ZW", "SS", "TA"]

尝试将旧的 rails 3.2.19 应用程序升级到 4.0.13(最新的 4.0.x),在对代码进行了所有必要的更改之后,我的应用程序卡在了

/host_share/my_application/config/initializers/countries.rb:4:in `<top (required)>': undefined method `priority_countries=' for Carmen:Module (NoMethodError)
    from /home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-4.0.13/lib/active_support/dependencies.rb:223:in `load'
    from /home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-4.0.13/lib/active_support/dependencies.rb:223:in `block in load'
    from /home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-4.0.13/lib/active_support/dependencies.rb:214:in `load_dependency'
    from /home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-4.0.13/lib/active_support/dependencies.rb:223:in `load'
    from /home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.13/lib/rails/engine.rb:609:in `block (2 levels) in <class:Engine>'
    from /home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.13/lib/rails/engine.rb:608:in `each'
    from /home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.13/lib/rails/engine.rb:608:in `block in <class:Engine>'
    from /home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.13/lib/rails/initializable.rb:30:in `instance_exec'
    from /home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.13/lib/rails/initializable.rb:30:in `run'
    from /home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.13/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /home/vagrant/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
    from /home/vagrant/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
    from /home/vagrant/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/tsort.rb:210:in `block (2 levels) in each_strongly_connected_component_from'
    from /home/vagrant/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
    from /home/vagrant/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/tsort.rb:209:in `block in each_strongly_connected_component_from'
    from /home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.13/lib/rails/initializable.rb:44:in `each'
    from /home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.13/lib/rails/initializable.rb:44:in `tsort_each_child'
    from /home/vagrant/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/tsort.rb:203:in `each_strongly_connected_component_from'
    from /home/vagrant/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
    from /home/vagrant/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/tsort.rb:180:in `each'
    from /home/vagrant/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
    from /home/vagrant/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
    from /home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.13/lib/rails/initializable.rb:54:in `run_initializers'
    from /home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.13/lib/rails/application.rb:215:in `initialize!'
    from /home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /host_share/my_application/config/environment.rb:5:in `<top (required)>'
    from /home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-4.0.13/lib/active_support/dependencies.rb:229:in `require'
    from /home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-4.0.13/lib/active_support/dependencies.rb:229:in `block in require'
    from /home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-4.0.13/lib/active_support/dependencies.rb:214:in `load_dependency'
    from /home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/activesupport-4.0.13/lib/active_support/dependencies.rb:229:in `require'
    from /home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.13/lib/rails/application.rb:189:in `require_environment!'
    from /home/vagrant/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.13/lib/rails/commands.rb:44:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

更新: 此代码Carmen.priority_countries是 carmen 0.2.8版的一部分,最新版本不再支持,

所以新的问题是如何更改我的代码以使其相应地工作?

4

0 回答 0