On Saturday, July 28, 2012 6:08:48 PM UTC+1, Roman wrote:
>
> Let `User.has_one :profile`. I've always thought that 
> `@user.build_profile` is a cheap thing to do - it's just creating a new 
> object without persisting it. But, in fact, it does 2 queries to the DB: 
> `BEGIN` and `COMMIT`.
>
>
I've never seen this before. Is there anything interesting about your 
profile class ?

Fred
 

> In my app I have an admin users#index page where users' details can be 
> edited, and to simplify the code I build a profile whenever it's `nil`, so 
> I get 2 queries for each user, which increases the page load time by a 
> factor. So I'd like to know if this is a bug in Rails worth fixing or that 
> transaction is really necessary when building an association?
>
> Thanks,
> Roman
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/d6GhuX3Ao8oJ.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to