Rails form validation conditional bypass

后端 未结 4 601
眼角桃花
眼角桃花 2020-12-08 11:34

I have a rails model that validates uniqueness of 2 form values. If these 2 values aren\'t unique the validation errors are shows and the \"submit\" button is changed to \"

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-08 12:13

    Try this:

    Rails 2: Model.save(false)
    Rails 3: Model.save(:validate => false)

    It bypasses validations (all of them though).

提交回复
热议问题