Created
December 17, 2012 08:07
-
-
Save anonymous/4316571 to your computer and use it in GitHub Desktop.
This file contains 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
Here's what I'm using. Maybe you could adapt it to your case. I have this on a Message model. | |
def method_missing(method_name, *args, &block) | |
if method_name =~ /(.*)_recipients$/ | |
self.correspondences.where('recipient_type = ?', $1.to_s.humanize) | |
.collect{ |c| c.recipient }.flatten.uniq | |
else | |
super | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment