I have two models

class User
has_one :entry
end


class Entry
belongs_to: user
end

in my controller I use find_each to iterate over entries to email each
of the users.


Entry.find_each(:include => :user, :conditions => {:approved =>
true}) do |entry|
UserMailer.send_competition_open_email(entry, entry.user)
end


entry.user is always nil..

yet i can see in my SQL logs it tries to get it. But fails. Any ideas?

Entry Load (0.6ms) SELECT `entries`.* FROM `entries` WHERE
`entries`.`approved` = 1 AND (`entries`.`id` >= 0) ORDER BY
`entries`.`id` ASC LIMIT 1000
User Load (1.4ms) SELECT `users`.* FROM `users` WHERE (`users`.`id`
IN (1,2,3))
User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`id`
= 1 LIMIT 1


--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 6 | next ›
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedOct 26, '11 at 2:40p
activeOct 27, '11 at 4:31p
posts6
users4
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2021 Grokbase