Congratulations to the solvers of Riddle #1! Tom Amel Ben Maraney The correct answer is: before_create will not work because the user is still not

rails-riddles-newsletter-header

Congratulations to the solvers of Riddle #1!

Tom Amel
Ben Maraney

The correct answer is:
before_create will not work because the user is still not saved and has no ID.
Since active record performs all callbacks in a single transaction with the original action, after_create is the most suitable one, since we probably want the user and profile creation to be performed in the same transaction. This will guarantee that if the profile fails to be saved, the user creation will rollback, and vice versa.

***

Riddle #2 - Improve / Fix as many things in the code below:

Screen Shot 2013-07-28 at 10.22.10 AM

Link to Gist

Send us your answers (privately) to hackademy@500tech.com

First three correct people to answer correctly will be featured on the Answers Email with a link to a url of their choice.

Good Luck!
500Tech Team
Signup here to receive Rails Riddles to your inbox

hackademy-footer-small
facebook google_plus linkedin twitter
1px