rails 4 before_validation on: :create or on: :save

The before_validation callback allows restrictions to particular events within the lifecycle of an object.

You can use the following syntax:

before_validation :set_uuid, on: :create
before_validation :upload_to_system, on: [:create, :update]

Here is the documentation of this option for Rails 4.0, Rails 5.2, Rails 6.0 and Rails 7.0.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)