Skip to content

Instantly share code, notes, and snippets.

Created December 17, 2012 08:07
Show Gist options
  • Save anonymous/4316571 to your computer and use it in GitHub Desktop.
Save anonymous/4316571 to your computer and use it in GitHub Desktop.
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