Hello Vahagn,
I suggest you do it as follows:
a) old-fashioned way by using puts liberally &
b) take baby steps
until it is debugged.
Your code with puts statements inserted; just an example:
def sendmails
newsletter = Newsletter.find_by_id_and_sent(params[:id], false)
users = User.find(:all)
# do not raise anything... confuses Ruby interpretor
puts users
users.each do |user|
puts user
#Notifier.deliver_newsletter(user, newsletter)
end
#newsletter.update_attribute('sent', true)
#redirect_to newsletters_path
end
Make sure first that the each iterator is printing your object instances
correctly. You can use "pp" short for pretty-print if you want but
then you will have to require it. puts is built into the language and
most of the times, it is sufficient.
This way, you can be absolutely sure that nothing unexpected is
happening with your basic loop. Once you are sure then you can
uncomment each statement one by one, e.g., uncomment Notifier.... first
and test. If that works then go to newslettr.update...
Hope this helps.
Bharat
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---