Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 4 升级到Rails 4时出错(未打开读取)_Ruby On Rails 4 - Fatal编程技术网

Ruby on rails 4 升级到Rails 4时出错(未打开读取)

Ruby on rails 4 升级到Rails 4时出错(未打开读取),ruby-on-rails-4,Ruby On Rails 4,我尝试将一个应用程序从3.2升级到rails 4。我认为所有的gems冲突现在都已经解决了,尽管后来我知道可能会再次发生 当我尝试“捆绑exec rails s”并在浏览器中打开应用程序时,会出现以下错误: IOError(未打开读取) 有人能帮忙吗?非常感谢你 以下是我使用的gem列表: gem 'rails', '4.0.1' gem 'sass-rails', '~> 4.0.0' gem 'coffee-rails', '~> 4.0.0' gem 'uglifier'

我尝试将一个应用程序从3.2升级到rails 4。我认为所有的gems冲突现在都已经解决了,尽管后来我知道可能会再次发生

当我尝试“捆绑exec rails s”并在浏览器中打开应用程序时,会出现以下错误:

IOError(未打开读取)

有人能帮忙吗?非常感谢你

以下是我使用的gem列表:

gem 'rails', '4.0.1'

gem 'sass-rails',   '~> 4.0.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'

gem 'jquery-rails'

gem 'jbuilder', '~> 1.2'
# add these gems to help with the transition:
gem 'protected_attributes'
gem 'rails-observers'
gem 'actionpack-page_caching'
gem 'actionpack-action_caching'
gem "activerecord-session_store"
以下是console的日志消息:

Started GET "/" for 127.0.0.1 at 2013-11-06 20:16:27 +1100
Processing by HomeController#index as HTML
  PCategory Load (0.5ms)  SELECT "p_categories".* FROM "p_categories"
  Rendered home/index.html.erb within layouts/application (4.1ms)
Completed 500 Internal Server Error in 15ms

IOError (not opened for reading):
  activesupport (4.0.1) lib/active_support/json/encoding.rb:256:in `each'
  activesupport (4.0.1) lib/active_support/json/encoding.rb:256:in `to_a'
  activesupport (4.0.1) lib/active_support/json/encoding.rb:256:in `as_json'
  activesupport (4.0.1) lib/active_support/json/encoding.rb:58:in `block in as_json'
  activesupport (4.0.1) lib/active_support/json/encoding.rb:81:in 'check_for_circular_references'
  activesupport (4.0.1) lib/active_support/json/encoding.rb:57:in `as_json'
  activesupport (4.0.1) lib/active_support/json/encoding.rb:296:in `block in as_json'
  activesupport (4.0.1) lib/active_support/json/encoding.rb:296:in `each'
  activesupport (4.0.1) lib/active_support/json/encoding.rb:296:in `map'
  activesupport (4.0.1) lib/active_support/json/encoding.rb:296:in `as_json'
  activesupport (4.0.1) lib/active_support/json/encoding.rb:58:in `block in as_json'
  activesupport (4.0.1) lib/active_support/json/encoding.rb:81:in g`check_for_circular_references'
  activesupport (4.0.1) lib/active_support/json/encoding.rb:57:in `as_json'
  activesupport (4.0.1) lib/active_support/json/encoding.rb:296:in `block in as_json'
  activesupport (4.0.1) lib/active_support/json/encoding.rb:296:in `each'
  activesupport (4.0.1) lib/active_support/json/encoding.rb:296:in `map'
  activesupport (4.0.1) lib/active_support/json/encoding.rb:296:in `as_json'
  activesupport (4.0.1) lib/active_support/json/encoding.rb:50:in `block in encode'
  activesupport (4.0.1) lib/active_support/json/encoding.rb:81:in `check_for_circular_references'
  activesupport (4.0.1) lib/active_support/json/encoding.rb:49:in `encode'
  activesupport (4.0.1) lib/active_support/json/encoding.rb:306:in `block in encode_json'
  activesupport (4.0.1) lib/active_support/json/encoding.rb:306:in `each'
  activesupport (4.0.1) lib/active_support/json/encoding.rb:306:in `map'

我最近也经历过这个问题。经过几天的反复试验,我最终注释了一组开发组gem(幸运猜测),然后逐个重新启用每个gem,用每个新启用的gem重建我的gem集。罪魁祸首原来是gem及其依赖项(它做了一些JSONP工作)

因此,我建议如下:

  • 清空您的gem集(
    rvm gemeset Empty
    如果您使用的是rvm)
  • 将Gemfile.lock文件重命名为Gemfile.lock.OLD(这可能不是必需的,但仅列出以防万一)
  • 在您的Gemfile中,注释掉您怀疑处理请求或执行JSON工作的任何gem
  • 运行
    bundle install
    以在没有注释掉gem的情况下重建gem集
  • 重新启动服务器。如果仍然收到IOError,请重复步骤1-5。否则,继续执行步骤6
  • 联合国评论你评论掉的宝石之一
  • 运行
    bundle install
    安装gem及其依赖项
  • 重新启动服务器。如果没有遇到IOR错误,请重复步骤6-8。否则,您上次启用的gem就是原因

  • 事实证明,创业板冲突是我遇到的类似问题的罪魁祸首。我修复了一个使用Rails的间接相关问题中的代码问题。请看下面,我希望这对你有帮助

    #fix for JSON gem/activesupport bug. More info: http://stackoverflow.com/questions/683989/how-do-you-deal-with-the-conflict-between-activesupportjson-and-the-json-gem
    if defined?(ActiveSupport::JSON)
      [Object, Array, FalseClass, Float, Hash, Integer, NilClass, String, TrueClass].each do |klass|
        klass.class_eval do
          def to_json(*args)
            super(args)
          end
          def as_json(*args)
            super(args)
          end
        end
      end
    end
    

    我在ActiveModel序列化程序中体验到了这一点。我将ActiveModel序列化程序从0.8.1升级到了0.9,之后运行良好。

    问题出在哪个gem上?恐怕这是很久以前的事了