Created
April 20, 2012 11:22
-
-
Save donnykurnia/2427868 to your computer and use it in GitHub Desktop.
find or create parent object from children association
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
def autosave_associated_records_for_team | |
if team.name.blank? | |
self.team_id = 1 | |
else | |
# Find or create the team by name | |
self.team = Team.find_or_create_by_name(team.name) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment