0
我認爲這可能是在其他地方回答的,但我並不是100%確定要查找什麼來尋找答案。RoR:max_users沒有保存?
我想在我length_of_users
方法來設置max_users
,但由於某種原因它沒有被保存,然後當length_of_users出現,MAX_USERS被顯示爲nil
。
任何幫助,非常感謝。提前致謝。
這裏是我的資產模型代碼:
在毫不相關的代碼validate :length_of_users
.
.
.
after_initialize :set_max_users
.
.
.
def set_max_users
if max_users.nil?
max_users = 1
end
end
.
.
.
def length_of_users
if user_ids.count > max_users
errors.add(:users, "You can only add a maximum of #{max_users} users")
end
end
的...
都顯示空白。
我不能相信我錯過了。非常感謝。 – Briknthewall 2014-11-06 15:43:55