Hello,-

I am developing a rails app with this method in it:

 # PUT /newsletters/1;send
  def sendmails
    newsletter = Newsletter.find_by_id_and_sent(params[:id], false)
    users = User.find(:all)
    raise users.to_yaml
    #debugger
    users.each do |user| #evaluates to nil.each - debug
      Notifier.deliver_newsletter(user, newsletter)
    end
    newsletter.update_attribute('sent', true)
    redirect_to newsletters_path
  end

I get an error saying that users.each do |user| evaluates to nil.each,
and that I probably expected an Array object there. This is true, I did
expect an Array object. Thing is, now I've tried to debug the code with
both debugger and raise to_yaml, and both times the users variable
evaluates to a perfect Array of 3 Users, exactly in correspondence with
the DB! I have also tried to debug the user variable and it evaluates to
a User with id 1, meaning the iterator fetches that user successfully
from the Array.

Yet after the first iteration, I get an error / crash.

I have tried to change users to @users, with the exact same result.
Debugging shows an Array of 3 user objects. The app crashes.

What is going on here?

Thanks in advance, Vahagn
-- 
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to