search for: possible_accounts

Displaying 1 result from an estimated 1 matches for "possible_accounts".

2011 Nov 02
2
Specify and validate requirements on an ActiveRecord association
...iations, nor does it imply that. A useful syntax might be: `PaymentMethod.has_many :accounts, requirement: proc {self.user == target.user}, scope: true, validate: true` Expressing `my_payment_method.accounts` would use `requirement` as a condition. A reflection on the association (`PaymentMethod.possible_accounts`) could return a relation that could be used to scope out the possible valid associations from the target (`Accounts`). The validate flag could generate a matching DRY validation that ensures the same condition at the instance level. Realizing that crossing realms of associations and validations m...