简体   繁体   中英

How to tell if there was a save or validation attempt in a Rails model?

I need to check if a model has had any attempt to be saved or validated without actually saving/validating it. The method #valid? does run the validations, so it doesn't fit here.

You can add a custom validation method . Your method will be executed on any validation attempt. You can set a flag inside your validation method to know if it has been executed. But I see no point in this task. I doubt you really should do this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM