2011-10-06 6 views
6

관련, 레일 응용 프로그램 내 루비에서 반복되는 버그는 여기에 많은 개월입니다 : 코드 변경을 보여준다는 점에서올드 루비 버그 Class.create 및 delayed_job

http://www.ruby-forum.com/topic/1094002

두 링크 :

https://github.com/godfat/ruby/commit/f4e0e8f781b05c767ad2472a43a4ed0727a75708 https://github.com/godfat/ruby/commit/c7a6cf975d88828c2ed27d253f41c480f9b66ad6

나는 루비 1.9.2와 RVM 있습니다. 이러한 변경 사항을 적절한 파일에 붙여 넣었 겠지만 어떻게해야할지 모르겠다.

며칠 전에 작업했습니다. 나는 할 수 없어 같은 루비 온 레일즈 명령 : 나는 죽은입니다

after_create do |user| 
    user.delay(:priority => -15).seed 
end 

:

ArgumentError: wrong number of arguments(1 for 0) 
from /Users/RedApple/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:48:in `method' 
from /Users/RedApple/.rvm/rubies/ruby-1.9.2 p290/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:48:in `accept' 
from /Users/RedApple/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:36:in `<<' 
from /Users/RedApple/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:165:in `dump' 
from /Users/RedApple/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/core_ext.rb:13:in `psych_to_yaml' 
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=' 
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' 
from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/base.rb:2914:in `each' 
from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/base.rb:2914:in `assign_attributes' 
from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/base.rb:2787:in `attributes=' 
from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/base.rb:2477:in `initialize' 
from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/base.rb:725:in `new' 
from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/base.rb:725:in `create' 
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' 
from /Users/RedApple/S/app/models/user.rb:29:in `block in <class:User>' 
from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-2.3.14/lib/active_support/callbacks.rb:182:in `call' 
... 7 levels... 
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' 
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' 
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' 
from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/base.rb:2577:in `save' 
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' 
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' 
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' 
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' 
from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/transactions.rb:182:in `transaction' 
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' 
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' 
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!' 
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' 
from /Users/RedApple/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.14/lib/active_record/base.rb:727:in `create' 
from (irb):1 
from /Users/RedApple/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in `<main>'> 
user.rb에서

라인 28 ~ 30 : 여기

>> User.create :username => "a", :password => "a" 

오류 메시지입니다 이것없이 물 속에. 누구든지 도와 줄 수 있습니까?

+0

업데이트 : 를 Ruby 1.8.7을 사용하도록 전환했는데 더 이상 문제가되지 않습니다. 즉, 분명히 Ruby 1.9.2 버그입니다. 개발과 생산에서 동일한 환경을 사용하는 것이 가장 좋기 때문에 저는 여전히 해결책을 원합니다. – Eric

+0

업데이트 : 1.8.7에서 작동하지만 1.8.7과 관련된 다른 문제가 있으므로 1.9.2에서 실제로 작동해야합니다. – Eric

답변

6

지연된 작업과 Ruby 1.9.2 YAML 파서 (Psych)는 불행히도 호환되지 않습니다. Bundler.require에 바로 전화 아래에, 당신의 config/application.rb이를 추가하여 다시 이전 YAML 파서 (Syck)에

스위치 :

YAML::ENGINE.yamler = "syck" if RUBY_VERSION >= "1.9.2" 
+0

고마워. 실제로 config/environment.rb에 붙여 넣었습니다. 이제 작동합니다. – Eric

+0

이것은 나에게 좋은 해결책이 아닌 것 같습니다. 모든 문서는 이제 Psych가 선호하는 YAML 백엔드임을 나타냅니다. – simianarmy

+0

@simianarmy, 아주 좋습니다. 그러나 지연된 작업이 수정 될 때까지 다른 방법은 없습니다. – molf

1

당신은 당신의 루비 패치 수 있지만가 정말 가능 용이하지 않다 관리되는 호스트. 내 솔루션 31075.

이 레일에 초기화 파일을 만듭니다 커밋 패치를 기반으로 monkeypatch을 만드는 것이었다 프로젝트 설정/초기화/psych_extensions.rb 이 코드를 추가

# APPLIES RUBY PATCH REVISION 31075 

module Psych 
    module Visitors 
    ### 
    # YAMLTree builds a YAML ast given a ruby object. For example: 
    # 
    # builder = Psych::Visitors::YAMLTree.new 
    # builder << { :foo => 'bar' } 
    # builder.tree # => #<Psych::Nodes::Stream .. } 
    # 
    class YAMLTree < Psych::Visitors::Visitor 

     def accept target 
     # return any aliases we find 
     if node = @st[target.object_id] 
      node.anchor = target.object_id.to_s 
      return @emitter.alias target.object_id.to_s 
     end 

     if target.respond_to?(:to_yaml) 
      loc = target.public_method(:to_yaml).source_location.first 
      if loc !~ /(syck\/rubytypes.rb|psych\/core_ext.rb)/ 
      unless target.respond_to?(:encode_with) 
       if $VERBOSE 
       warn "implementing to_yaml is deprecated, please implement \"encode_with\"" 
       end 

       target.to_yaml(:nodump => true) 
      end 
      end 
     end 

     if target.respond_to?(:encode_with) 
      dump_coder target 
     else 
      send(@dispatch_cache[target.class], target) 
     end 
     end 

     private 

     # FIXME: remove this method once "to_yaml_properties" is removed 
     def find_ivars target 
     loc = target.public_method(:to_yaml_properties).source_location.first 
     unless loc.start_with?(Psych::DEPRECATED) || loc.end_with?('rubytypes.rb') 
      if $VERBOSE 
      warn "#{loc}: to_yaml_properties is deprecated, please implement \"encode_with(coder)\"" 
      end 
      return target.to_yaml_properties 
     end 

     target.instance_variables 
     end 

    end 
    end 
end