I have a table of emails. And i need that Each user received email. SO i made: script/generate mailer Notifier Next. class Notifier < ActionMailer::Base def newgrants_notification(respondent) recipients user.email from "lala-GBs+9h5cdSg@public.gmane.org" subject "Hi!" body (:respondent => respondent) end end In app/views/notifier/newgrants_notification.erb wrote : Hello! and this my controller where i create question @question = Question.create(:text => params[:question][:text], :security => rand(888).to_i) if success = @question.save respondents = Respondent.find(:all) respondents.each do |res| Inquiry.create(:question_id=>@question.id.to_i, :respondent_id=>res.id.to_i) Notifier.newgrants_notification(respondents).deliver #this is right?? end what mistakes i did? messages aren''t coming ;( -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Apr 11, 8:19 am, vone vonich <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> > In app/views/notifier/newgrants_notification.erb wrote : Hello! > > and this my controller where i create question > > @question = Question.create(:text => params[:question][:text], :security > => rand(888).to_i) > > if success = @question.save > respondents = Respondent.find(:all) > respondents.each do |res| > Inquiry.create(:question_id=>@question.id.to_i, > :respondent_id=>res.id.to_i) > Notifier.newgrants_notification(respondents).deliver #this is > right?? > end > > what mistakes i did? messages aren''t coming ;(How have you configured actionmailer? The default is to use sendmail, but that will only work if you have a functioning sendmail install on the machine you are running on. Fred -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
On 11 April 2011 08:19, vone vonich <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I have a table of emails. And i need that Each user received email. > > SO i made: > > script/generate mailer Notifier > > Next. > > class Notifier < ActionMailer::Base > def newgrants_notification(respondent) > recipients user.email > from "lala-GBs+9h5cdSg@public.gmane.org" > subject "Hi!" > body (:respondent => respondent) > end > endIn line 3 of this, you''re using the local variable ''user'', which doesn''t exist, so it''s probably throwing an error. (In fact, if you got an error, could you share it with us so that we can help better?) You probably want ''respondent'' there instead. Also, note that your method ''newgrants_notification'' takes a *single* respondent as a parameter...> In app/views/notifier/newgrants_notification.erb wrote : Hello! > > and this my controller where i create question > > @question = Question.create(:text => params[:question][:text], :security > => rand(888).to_i) > > if success = @question.save > respondents = Respondent.find(:all) > respondents.each do |res| > Inquiry.create(:question_id=>@question.id.to_i, > :respondent_id=>res.id.to_i) > Notifier.newgrants_notification(respondents).deliver #this is > right?? > end...while in this code, you call ''newgrants_notification'' with an *array* of users (''respondents''). You probably intended to pass a single respondent (in that block, ''res'') to the method. Chris -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.