0
該軌道項目是非常裸機,纔剛剛開始,所以我沒有做任何奇怪的漏洞或修補。Rails的:不能轉換的ActiveRecord ::協會:: BelongsToAssociation成字符串
模型,to_s取代學校用吧,如果零:
class Department < ActiveRecord::Base
belongs_to :school
def to_s
"foo" + (school || "bar")
end
end
說的觀點:
can't convert ActiveRecord::Associations::BelongsToAssociation into String
有關to_s聲明
但在腳本/控制檯,我可以帶一個部門d,其中學校==零和說
"foo" + (d.school || "bar")
,並得到 「foobar的」
給出了同樣的錯誤。 – themirror 2010-06-04 19:26:59