Ned
(Ned)
1
So I have....
class Post < ActiveRecord::Base
belongs_to :user
end
@posts = Post.find :all, :include=>:user
.... but when I look at my logs I see this:
Post Load (2.4ms) SELECT * FROM `posts`
User Load (0.2ms) SELECT * FROM `users` WHERE (`users`.`id` = 1)
I was expecting one combined SQL statement?
Any ideas?
thanks
vimal
(vimal)
3
what exactly do you want to do???
for me it looks like you want all the posts for the particular user
then it should be @posts = User.posts
Ned
(Ned)
4
what exactly do you want to do???
I just didn't want to make a new query everytime i accessed a user of
a post
However, Fred is right Rolling with Rails 2.1 - The First Full Tutorial - Part 2 | AkitaOnRails.com
So 2 queries is ok!
thanks guys