0
我正在將舊版項目從Rails 2.3.2升級到2.3.16(由於最近公佈的漏洞),但是當我嘗試訪問has_many
關聯在任何型號上,我從sanitize_sql
獲得ArgumentError
。Rails 2.3.16關聯在使用關聯時給出ArgumentError
class User
has_many :games, :dependent => destroy
end
class Game
belongs_to :user
end
當我嘗試並調用Game.last.user
它返回正確User
對象,但調用User.last.games
我碰到下面的錯誤堆棧:
ArgumentError: wrong number of arguments (2 for 1)
from /home/username/application/shared/bundle/ruby/1.8/gems/activerecord-2.3.16/lib/active_record/associations/association_proxy.rb:174:in `sanitize_sql'
from /home/username/application/shared/bundle/ruby/1.8/gems/activerecord-2.3.16/lib/active_record/associations/association_proxy.rb:174:in `send'
from /home/username/application/shared/bundle/ruby/1.8/gems/activerecord-2.3.16/lib/active_record/associations/association_proxy.rb:174:in `sanitize_sql'
from /home/username/application/shared/bundle/ruby/1.8/gems/activerecord-2.3.16/lib/active_record/associations/association_collection.rb:41:in `find'
from /home/username/application/shared/bundle/ruby/1.8/gems/activerecord-2.3.16/lib/active_record/associations/association_collection.rb:423:in `find_target'
from /home/username/application/shared/bundle/ruby/1.8/gems/activerecord-2.3.16/lib/active_record/associations/association_collection.rb:365:in `load_target'
from /home/username/application/shared/bundle/ruby/1.8/gems/activerecord-2.3.16/lib/active_record/associations/association_proxy.rb:140:in `inspect'
from /home/username/.rvm/rubies/ruby-1.8.7-p371/lib/ruby/1.8/irb.rb:310:in `output_value'
from /home/username/.rvm/rubies/ruby-1.8.7-p371/lib/ruby/1.8/irb.rb:159:in `eval_input'
from /home/username/.rvm/rubies/ruby-1.8.7-p371/lib/ruby/1.8/irb.rb:271:in `signal_status'
from /home/username/.rvm/rubies/ruby-1.8.7-p371/lib/ruby/1.8/irb.rb:155:in `eval_input'
from /home/username/.rvm/rubies/ruby-1.8.7-p371/lib/ruby/1.8/irb.rb:154:in `eval_input'
from /home/username/.rvm/rubies/ruby-1.8.7-p371/lib/ruby/1.8/irb.rb:71:in `start'
from /home/username/.rvm/rubies/ruby-1.8.7-p371/lib/ruby/1.8/irb.rb:70:in `catch'
from /home/username/.rvm/rubies/ruby-1.8.7-p371/lib/ruby/1.8/irb.rb:70:in `start'
from /home/username/.rvm/rubies/ruby-1.8.7-p371/bin/irb:17
我關於Ruby 1.8.7運行的Rails 2.3.16 ;如果還有其他細節可以幫助我診斷問題,請告訴我。
編輯
我似乎已經解決這個問題,通過編輯錯誤導致線在activerecord-2.3.16/lib/active_record/associations/association_proxy.rb
文件像這樣暫時的工作:
# Forwards the call to the reflection class.
def sanitize_sql(sql, table_name = @reflection.klass.quoted_table_name)
@reflection.klass.send(:sanitize_sql, sql) #, table_name)
end
我想,很明顯,喜歡比較長因爲我不能100%確定這不會有額外的連鎖問題。
你ree版本的補丁級別是什麼?你仍然使用ree1.8.7-2012.02得到相同的錯誤?我在ree-1.8.7-2011.12 – Regedor
上遇到了一些問題,我使用的是ruby-1.8.7-p371,但我會給ree一個鏡頭,看看是否有幫助。 – PaulC
不,改用ree-1.8.7-2012.02似乎沒有解決問題。 – PaulC