i have validation needs apply per project user in. solution came call model method controller:
controller:
client.validate_uniq_record(params[:project_id])
model:
def self.validate_uniq_record(proj_id) validates_uniqueness_of :item, scope: :price, conditions: -> {where(project_id: proj_id)} end
from reading other questions, looks passing param model big nono: how access params in callback of rails model? not figure out how through virtual attribute either.
how validates_uniqueness_of
current project user in?
note, client
object has project_id
column fk
Comments
Post a Comment