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