Last active
August 29, 2015 14:20
-
-
Save Fivell/36674c6875be382fb52a to your computer and use it in GitHub Desktop.
access to parent object from has_many
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class User < ActiveRecord::Base | |
| has_many :payments, class_name: 'Payment', foreign_key: :user_id do | |
| def scoped_user | |
| proxy_association.owner | |
| end | |
| end | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment