Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Ability to specify multiple contexts when defining a validation. #13754
This feature is very useful thank you. I have the following suggestion: when someone specifies a validation with context :save, it should be called for :create and :update.
For example, if you have two steps, the first step someone needs to enter his name, the second step his lastname, but it should only be able to save if name, surname and token is populated, you currently have to do it like this:
validates :name, presence: true, on: [:create, :update, :step1]
It would be much simpler if you could write it as:
validates :name, presence: true, on: [:save, :step1]
In fact, consider the how callbacks are specified (before_save, before_create, before_update) this actually seems like a bug.