Skip to content

Instantly share code, notes, and snippets.

@roy
Created February 11, 2011 12:29
Show Gist options
  • Save roy/822276 to your computer and use it in GitHub Desktop.
Save roy/822276 to your computer and use it in GitHub Desktop.
To code smell, or not to code smell: that is the question
# old
def build_form_response
form_response = self.form_responses.new
self.questions.each do |question|
form_response.answers.build(:question => question)
end
form_response
end
# using tap
def build_form_response
self.form_responses.new.tap do |form_response|
self.questions.each do |question|
form_response.answers.build(:question => question)
end
end
end
@daxhuiberts
Copy link

WHAZAAAAAAAAAAAAAP!!!!!

@roy
Copy link
Author

roy commented Feb 11, 2011

:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment