Skip to content

Instantly share code, notes, and snippets.

@myobie
Created July 17, 2009 13:22
Show Gist options
  • Save myobie/149047 to your computer and use it in GitHub Desktop.
Save myobie/149047 to your computer and use it in GitHub Desktop.
association = history.ticket.model.relationships.select { |key, value|
value.child_key.named?(field_name.to_sym) && value.child_key.length == 1
}
unless association.empty? || association.first.length != 2
self.belongs_to_class = association.first[1].parent_model.to_s
end#of unless
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment