1
我的下一個領域對象:紅寶石計數對象屬性
class Post
field :repost , type: Integer
attr_accessible :repost
end
在我的行動轉貼控制器,我想增加計數器+ 1
我嘗試:
@post.repost += 1
,但我得到:
NoMethodError (You have a nil object when you didn't expect it!
You might have expected an instance of Array.
我該如何解決它?
你嘗試設置一個默認值,你的領域? – apneadiving 2012-02-06 13:00:03