Looking through the rails code, I can't see where conditional validation gets executed... when you pass a string or an symbol to :if
it supposedly does an eval
for strings and a send
for symbols... where does that happen?
Been trying to follow it through the code but I can't find where the if
options are split into send
or eval
and how that all works. Just trying to learn and follow the through how rails does it.
https://github.com/rails/rails/blob/master/activemodel/lib/active_model/validator.rb https://github.com/rails/rails/blob/master/activemodel/lib/active_model/validations.rb
Thanks!
This method is responsible for all the symbols, strings and lambdas being executed. Seems that Rails is using activesupport callbacks
to implement validations.
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.