簡體   English   中英

Yaml Dump with rails 2.3和ruby 2.0

[英]Yaml dump with rails 2.3 and ruby 2.0

我已經將Rails 2.3應用程序從ruby 1.8升級到ruby 2.0。

現在,當我嘗試序列化活動記錄對象(YAML :: dump())時,出現以下錯誤:

ArgumentError (wrong number of arguments (2 for 0)):

完整堆棧跟蹤:

ArgumentError (wrong number of arguments (2 for 0)):  vendor/bundle/gems/activesupport-2.3.18/lib/active_support/ordered_hash.rb:16:in `block in to_yaml'
  /ruby/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/deprecated.rb:19:in `call' /ruby/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/deprecated.rb:19:in `block in quick_emit'
  /ruby/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:449:in `dump_coder'
  /ruby/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:126:in `accept'  /ruby/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:480:in `block in dump_ivars'
  /ruby/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:478:in `each'
  /ruby/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:478:in `dump_ivars'  /ruby/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:150:in `visit_Object'
  /ruby/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:128:in `accept'
  /ruby/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:480:in `block in dump_ivars' /ruby/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:478:in `each'
  /ruby/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:478:in `dump_ivars'
  /ruby/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:150:in `visit_Object'  /ruby/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:128:in `accept'
  /ruby/ruby-2.0.0-p353/lib/ruby/2.0.0/psych/visitors/yaml_tree.rb:92:in `push'
  /ruby/ruby-2.0.0-p353/lib/ruby/2.0.0/psych.rb:244:in `dump' app/models/customer_address.rb:121:in `store_customer_address'
  app/controllers/shop/buy_controller.rb:807:in `place_order'
  vendor/bundle/gems/actionpack-2.3.18/lib/action_controller/base.rb:1333:in `perform_action' vendor/bundle/gems/actionpack-2.3.18/lib/action_controller/filters.rb:617:in `call_filters'
  vendor/bundle/gems/actionpack-2.3.18/lib/action_controller/filters.rb:610:in `perform_action_with_filters'
  vendor/bundle/gems/actionpack-2.3.18/lib/action_controller/benchmarking.rb:68:in `block in perform_action_with_benchmark' vendor/bundle/gems/actionpack-2.3.18/lib/action_controller/benchmarking.rb:68:in `perform_action_with_benchmark'
  vendor/bundle/gems/actionpack-2.3.18/lib/action_controller/rescue.rb:160:in `perform_action_with_rescue'
  vendor/bundle/gems/actionpack-2.3.18/lib/action_controller/flash.rb:151:in `perform_action_with_flash'  vendor/bundle/gems/actionpack-2.3.18/lib/action_controller/base.rb:532:in `process'
  vendor/bundle/gems/actionpack-2.3.18/lib/action_controller/filters.rb:606:in `process_with_filters'
  vendor/bundle/gems/actionpack-2.3.18/lib/action_controller/base.rb:391:in `process' vendor/bundle/gems/actionpack-2.3.18/lib/action_controller/base.rb:386:in `call'
  vendor/bundle/gems/actionpack-2.3.18/lib/action_controller/routing/route_set.rb:438:in `call'
  vendor/bundle/gems/actionpack-2.3.18/lib/action_controller/dispatcher.rb:87:in `dispatch' vendor/bundle/gems/actionpack-2.3.18/lib/action_controller/dispatcher.rb:121:in `_call'
  vendor/bundle/gems/actionpack-2.3.18/lib/action_controller/dispatcher.rb:130:in `block in build_middleware_stack'
  vendor/bundle/gems/sass-3.3.8/lib/sass/plugin/rack.rb:54:in `call'  vendor/bundle/gems/sass-3.3.8/lib/sass/plugin/rack.rb:54:in `call'
  vendor/bundle/gems/actionpack-2.3.18/lib/action_controller/string_coercion.rb:25:in `call'
  vendor/bundle/gems/actionpack-2.3.18/lib/action_controller/params_parser.rb:15:in `call'  vendor/bundle/gems/actionpack-2.3.18/lib/action_controller/session/abstract_store.rb:177:in `call'
  vendor/bundle/gems/activerecord-2.3.18/lib/active_record/query_cache.rb:29:in `block in call'
  vendor/bundle/gems/activerecord-2.3.18/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'  vendor/bundle/gems/activerecord-2.3.18/lib/active_record/query_cache.rb:9:in `cache'
  vendor/bundle/gems/activerecord-2.3.18/lib/active_record/query_cache.rb:28:in `call'
  vendor/bundle/gems/activerecord-2.3.18/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'  app/middleware/flash_session_cookie_middleware.rb:20:in `call'
  vendor/bundle/gems/actionpack-2.3.18/lib/action_controller/failsafe.rb:26:in `call'
  vendor/bundle/gems/actionpack-2.3.18/lib/action_controller/dispatcher.rb:114:in `block in call' vendor/bundle/gems/actionpack-2.3.18/lib/action_controller/reloader.rb:34:in `run'
  vendor/bundle/gems/actionpack-2.3.18/lib/action_controller/dispatcher.rb:108:in `call'
  /passenger/passenger/lib/phusion_passenger/rack/thread_handler_extension.rb:61:in `process_request' /passenger/passenger/lib/phusion_passenger/request_handler/thread_handler.rb:127:in `accept_and_process_next_request'
  /passenger/passenger/lib/phusion_passenger/request_handler/thread_handler.rb:95:in `main_loop'
  /passenger/passenger/lib/phusion_passenger/request_handler.rb:464:in `block (3 levels) in start_threads'

我更新到了最新的心理圖書館,並試圖切換到syck,但沒有用。

問題是在Rails 2.3中,一旦在ActiveRecord :: Base對象上調用.valid ,@ errors實例變量將設置為ActiveSupport :: OrderedHash:

https://github.com/rails/rails/blob/3773c2fc1f63daf3a6f92ef49720e801988ac990/activerecord/lib/active_record/validations.rb#L297-L299

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM