I''m having some problems with ActionMailer and I''m hoping that someone can help. I''ve followed the tutorial on "How To Send Emails With Action Mailer" <URL: http://wiki.rubyonrails.com/rails/show/HowToSendEmailsWithActionMailer >, I''ve generated a mailer -- "notifier.rb" -- and I''ve added the following method to the mailer: def comment_notification(comment) @recipients = "email-J0of1frlU80@public.gmane.org" @body = comment end I''m calling the mailer method from within my application with the following lines: @comment = Comment.new(@params[''comment'']) Notifier::deliver_comment_notification(@comment[''comment'']) Upon calling the mailer method, I''m preseted with the following error: private method `gsub'' called for nil:NilClass Does anyone have any idea of what I''m doing wrong? -- Nathan Wright http://www.brandalism.com
On 10.3.2005, at 20:52, Nathan Wright wrote:> > > @comment = Comment.new(@params[''comment'']) > Notifier::deliver_comment_notification(@comment[''comment''])Might this be the source of your problem: @comment[''comment''] ? As I see it, @comment is not a hash but rather a Comment object. //jarkko> > > Upon calling the mailer method, I''m preseted with the following error: > > private method `gsub'' called for nil:NilClass > > > Does anyone have any idea of what I''m doing wrong? > > > -- > Nathan Wright > http://www.brandalism.com > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Jarkko Laine http://jlaine.net http://odesign.fi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
>> @comment = Comment.new(@params[''comment'']) >> Notifier::deliver_comment_notification(@comment[''comment'']) > > Might this be the source of your problem: @comment[''comment''] ? As I > see it, @comment is not a hash but rather a Comment object.Actually, the @comment is a hash; it''s a new object created when a comment form is submitted, and so it''s hash keys correspond with the fields in the original form. -- Nathan Wright http://www.brandalism.com
On 10.3.2005, at 21:25, Nathan Wright wrote:>>> @comment = Comment.new(@params[''comment'']) >>> Notifier::deliver_comment_notification(@comment[''comment'']) >> >> Might this be the source of your problem: @comment[''comment''] ? As I >> see it, @comment is not a hash but rather a Comment object. > > Actually, the @comment is a hash; it''s a new object created when a > comment form is submitted, and so it''s hash keys correspond with the > fields in the original form.Oh, cool, something new every day :-) //jarkko> > -- > Nathan Wright > http://www.brandalism.com > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Jarkko Laine http://jlaine.net http://odesign.fi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On Thu, 2005-03-10 at 11:52 -0700, Nathan Wright wrote:> I''m calling the mailer method from within my application with the > following lines: > > @comment = Comment.new(@params[''comment'']) > Notifier::deliver_comment_notification(@comment[''comment''])Not sure if this helps, but try: Notifier.deliver_comment_notification(@comment[''comment'']) cheers, mengkuan
is the method in your notiffier file just called: comment_notification or deliver_comment_notification? The deliver is not suppose to be their in the method name. Don''t understand yet why. On 10-Mar-05, at 8:23 PM, Meng Kuan wrote:> On Thu, 2005-03-10 at 11:52 -0700, Nathan Wright wrote: >> I''m calling the mailer method from within my application with the >> following lines: >> >> @comment = Comment.new(@params[''comment'']) >> Notifier::deliver_comment_notification(@comment[''comment'']) > > Not sure if this helps, but try: > > Notifier.deliver_comment_notification(@comment[''comment'']) > > cheers, > mengkuan > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >Your Friend, Jonathan Kopanas http://www.kopanas.com
On Thu, 10 Mar 2005 20:26:30 -0500, John Baku <john-CC0oh5EnFfVBDgjK7y7TUQ@public.gmane.org> wrote:> or deliver_comment_notification? The deliver is not suppose to be > their in the method name. Don''t understand yet why.It is not supposed to be in the method-name, because there are virtual methods calling the method which differ in behaviour: deliver_method-name delivers the mail, create_method-name just returns a tmail-Object which you can adjust to your needs.