92 notes &
Ruby Quicktips: Conditional Validation using with_options to improve readability
When you have a model that requires additional information, if a certain condition is met and you need to validate this attribute, this little trick can help.
Say we have a user model that needs to validate the
truck_serialattribute if the user has the role of driver:class User <...