I am looking for the best way to implement custom validations. I am aware of this :
validates :email, :uniqueness => {:scope => :user_id}
It works perfect. But, I want to do something like this (fictive case but it illustrates well) :
validates :email, :uniqueness => {:scope => 'user.name'}
I am thinking of using customs validations like explained here on rails cast but it seems a little overkill to use a module for this.
Anyone ?
Use a validation method.
Replace
Model.where(...).any?with your query.