
first_or_new through associations doesn't act as expected
Reported by handler | November 18th, 2010 @ 11:03 AM
if you use first_or_new through an association, like the following:
user = User.new
p1 = user.post.new
p2 = user.post.new
p1.locations.first_or_new(:lat => lat, :lng => lng)
p2.locations.first_or_new(:lat => lat, :lng => lng)
user.save
2 locations are created with the same lat/lng... i feel like it would be ideal if first_or_new on an association would wait until it saves before calling first(), that way this situation would only create 1 location and both posts would refer to it
Comments and changes to this ticket
-
Piotr Solnica (solnic) November 19th, 2010 @ 01:52 PM
- State changed from new to unconfirmed
- Tag changed from first_or_create to first_or_create, suggestion
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »