activesupport
Nothing to display jet.
Nothing to display jet.
Sometimes there are some external validations that are brought in our #active_record models by some gems. Usually these validations are useful, but sometimes we don't want such validations, if we want redefine some gem's behavior.
So, I show you how to cancel validation in ActiveRecord model, for example Devise's validation of email uniqueness. More under the cut
Also #activesupport provides custom callbacks for your methods.
At first you should define callback, then define methods and wrap your code to run_callbacks block. Example
If you wanna benchmark something in rails you shouldn't require some other libs.
#activesupport provides benchmark method available in your models, controllers and views. example
If you deal with non-latin utf-8 strings String#downcase method will not work. In #rails you can use #active_support String extension for it - String#mb_chars method. Example is under the cut. More under the cut
Somebody doesn't know what will happen after calling the callback who return false, but it is important thing to know about #activerecord. More under the cut