开发者

Rails 3: how to require at least one field not to be blank

开发者 https://www.devze.com 2023-02-16 23:15 出处:网络
I have a model that has several properties. I want to va开发者_StackOverflow中文版lidate that at least one of those properties is set. I saw the post here, but the errors.add_to_base is now deprecated

I have a model that has several properties. I want to va开发者_StackOverflow中文版lidate that at least one of those properties is set. I saw the post here, but the errors.add_to_base is now deprecated in Rails 3 and was wondering what the new solution might be.


It's now simply

errors.add(:base, "message")
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号