在特定的action里使用validates
Posted 冰凌花花~
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在特定的action里使用validates相关的知识,希望对你有一定的参考价值。
http://guides.rubyonrails.org/v3.0.8/active_record_validations_callbacks.html#on
在特定的action里使用validates
The :on option lets you specify when the validation should happen. The default behavior for all the built-in validation helpers is to be run on save (both when you’re creating a new record and when you’re updating it). If you want to change it, you can use :on => :create to run the validation only when a new record is created or :on => :update to run the validation only when a record is updated.
class Person < ActiveRecord::Base # it will be possible to update email with a duplicated value validates_uniqueness_of :email, :on => :create # it will be possible to create the record with a non-numerical age validates_numericality_of :age, :on => :update # the default (validates on both create and update) validates_presence_of :name, :on => :save end
以上是关于在特定的action里使用validates的主要内容,如果未能解决你的问题,请参考以下文章
表单(上)EasyUI Form 表单EasyUI Validatebox 验证框EasyUI Combobox 组合框EasyUI Combo 组合EasyUI Combotree 组合树((代码片
安装npm后,nrm ls 报错internal/validators.js:124 throw new ERR_INVALID_ARG_TYPE(name, ‘string‘, value)(代码片