Prev | Current Page 173 | Next

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"

info("Account data about to be validated for existing record")
end
end
This example assumes that we have a logger object to which we are recording certain
actions; we are logging the fact that our data is about to be passed to our validation methods
before executing a SQL update statement.
after_validation_on_update
This method is executed after an ActiveRecord::Validations.validate_on_update statement
or an ActiveRecord::Validations.validate statement is initiated from an ActiveRecord::
Base.save or ActiveRecord::Base.update statement on an object that already has a corresponding
record in the database.
class Account < ActiveRecord::Base
def after_validation_on_update
logger.info("Account data passed all validations for existing record")
end
end
This example assumes that we have a logger object to which we are recording certain actions.
Here, we log the fact that our data passed through all of our validation methods before executing
a SQL update statement.
before_destroy
before_destroy is executed before an ActiveRecord::Base.


Pages:
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185