Guest User

Untitled

a guest
Aug 21st, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.68 KB | None | 0 0
  1. Old Ruby bug is recurring in my Ruby on Rails app, related to Class.create and delayed_job
  2. >> User.create :username => "a", :password => "a"
  3.  
  4. ArgumentError: wrong number of arguments(1 for 0)
  5. from /Users/RedApple/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:48:in `method'
  6. from /Users/RedApple/.rvm/rubies/ruby-1.9.2 p290/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:48:in `accept'
  7. from /Users/RedApple/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:36:in `<<'
  8. from /Users/RedApple/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:165:in `dump'
  9. from /Users/RedApple/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/core_ext.rb:13:in `psych_to_yaml'
  10. from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-2.0.4/lib/delayed/backend/base.rb:57:in `payload_object='
  11. from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/base.rb:2918:in `block in assign_attributes'
  12. from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/base.rb:2914:in `each'
  13. from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/base.rb:2914:in `assign_attributes'
  14. from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/base.rb:2787:in `attributes='
  15. from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/base.rb:2477:in `initialize'
  16. from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/base.rb:725:in `new'
  17. from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/base.rb:725:in `create'
  18. from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/delayed_job-2.0.4/lib/delayed/message_sending.rb:9:in `method_missing'
  19. from /Users/RedApple/S/app/models/user.rb:29:in `block in <class:User>'
  20. from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:182:in `call'
  21. ... 7 levels...
  22. from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/callbacks.rb:267:in `create_with_callbacks'
  23. from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/base.rb:2927:in `create_or_update'
  24. from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/callbacks.rb:250:in `create_or_update_with_callbacks'
  25. from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/base.rb:2577:in `save'
  26. from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/validations.rb:1089:in `save_with_validation'
  27. from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/dirty.rb:79:in `save_with_dirty'
  28. from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/transactions.rb:229:in `block in with_transaction_returning_status'
  29. from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction'
  30. from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/transactions.rb:182:in `transaction'
  31. from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/transactions.rb:228:in `with_transaction_returning_status'
  32. from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/transactions.rb:196:in `block in save_with_transactions'
  33. from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/transactions.rb:208:in `rollback_active_record_state!'
  34. from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/transactions.rb:196:in `save_with_transactions'
  35. from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/base.rb:727:in `create'
  36. from (irb):1
  37. from /Users/RedApple/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in `<main>'>
  38.  
  39. after_create do |user|
  40. user.delay( :priority => -15 ).seed
  41. end
  42.  
  43. YAML::ENGINE.yamler = "syck" if RUBY_VERSION >= "1.9.2"
  44.  
  45. # APPLIES RUBY PATCH REVISION 31075
  46.  
  47. module Psych
  48. module Visitors
  49. ###
  50. # YAMLTree builds a YAML ast given a ruby object. For example:
  51. #
  52. # builder = Psych::Visitors::YAMLTree.new
  53. # builder << { :foo => 'bar' }
  54. # builder.tree # => #<Psych::Nodes::Stream .. }
  55. #
  56. class YAMLTree < Psych::Visitors::Visitor
  57.  
  58. def accept target
  59. # return any aliases we find
  60. if node = @st[target.object_id]
  61. node.anchor = target.object_id.to_s
  62. return @emitter.alias target.object_id.to_s
  63. end
  64.  
  65. if target.respond_to?(:to_yaml)
  66. loc = target.public_method(:to_yaml).source_location.first
  67. if loc !~ /(syck/rubytypes.rb|psych/core_ext.rb)/
  68. unless target.respond_to?(:encode_with)
  69. if $VERBOSE
  70. warn "implementing to_yaml is deprecated, please implement "encode_with""
  71. end
  72.  
  73. target.to_yaml(:nodump => true)
  74. end
  75. end
  76. end
  77.  
  78. if target.respond_to?(:encode_with)
  79. dump_coder target
  80. else
  81. send(@dispatch_cache[target.class], target)
  82. end
  83. end
  84.  
  85. private
  86.  
  87. # FIXME: remove this method once "to_yaml_properties" is removed
  88. def find_ivars target
  89. loc = target.public_method(:to_yaml_properties).source_location.first
  90. unless loc.start_with?(Psych::DEPRECATED) || loc.end_with?('rubytypes.rb')
  91. if $VERBOSE
  92. warn "#{loc}: to_yaml_properties is deprecated, please implement "encode_with(coder)""
  93. end
  94. return target.to_yaml_properties
  95. end
  96.  
  97. target.instance_variables
  98. end
  99.  
  100. end
  101. end
  102. end
Add Comment
Please, Sign In to add comment