我有一個「車」模型,它是一個ActiveRecord的:的Rails 3:錯誤時訪問活動記錄模型的屬性
class Car < ActiveRecord::Base
...
end
在DB的車表中,有一個名爲「可用列'其中包含布爾值。我嘗試在模型類像訪問此值:
class Car < ActiveRecord::Base
...
if self.avaliable #error msg: undefined method 'available'
end
end
但我得到錯誤信息「未定義的方法‘可用’」,爲什麼呢?如何訪問汽車模型的這個屬性?
是的,他可以。 'class Car
BitOfUniverse
2011-03-16 13:49:09
@Tumtu,thanx,對我來說是新的 – fl00r 2011-03-16 13:50:44