Strange mailer behaviour in Rails 4.2

16 views
Skip to first unread message

Damjan Rems

unread,
Feb 17, 2015, 4:58:47 AM2/17/15
to rubyonra...@googlegroups.com
The code inside test method doesn't get executed at all.

class MailSender < ActionMailer::Base
default :from => 'no.r...@some.where'

def test()
should_die_here
mail(
:to => 't...@to.com',
:subject => 'Test',
:text => 'Text').deliver
end
end


##########
In controller:

MailSender.test() # nothing happen
MailSender.test1() # throws error, method test1 not found.

First call should die in should_die_here line, but nothing happens.
Funny thing is if I try to call nonexisted method I get error, that
method does not exist.

When I reverted to rails 4.1.19 everything works as expected.


Thanks for your advice
TheR

--
Posted via http://www.ruby-forum.com/.

Colin Law

unread,
Feb 17, 2015, 5:06:51 AM2/17/15
to rubyonra...@googlegroups.com
On 17 February 2015 at 09:56, Damjan Rems <li...@ruby-forum.com> wrote:
> The code inside test method doesn't get executed at all.
>
> class MailSender < ActionMailer::Base
> default :from => 'no.r...@some.where'
>
> def test()

Should that not be
def self.test()
if you want to call it using
MailSender.test()

Colin

> should_die_here
> mail(
> :to => 't...@to.com',
> :subject => 'Test',
> :text => 'Text').deliver
> end
> end
>
>
> ##########
> In controller:
>
> MailSender.test() # nothing happen
> MailSender.test1() # throws error, method test1 not found.
>
> First call should die in should_die_here line, but nothing happens.
> Funny thing is if I try to call nonexisted method I get error, that
> method does not exist.
>
> When I reverted to rails 4.1.19 everything works as expected.
>
>
> Thanks for your advice
> TheR
>
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/cba0e7699a949aa76a01b3f98f49f477%40ruby-forum.com.
> For more options, visit https://groups.google.com/d/optout.

Damjan Rems

unread,
Feb 17, 2015, 5:14:07 AM2/17/15
to rubyonra...@googlegroups.com
Colin Law wrote in post #1168195:
> On 17 February 2015 at 09:56, Damjan Rems <li...@ruby-forum.com> wrote:
>> The code inside test method doesn't get executed at all.
>>
>> class MailSender < ActionMailer::Base
>> default :from => 'no.r...@some.where'
>>
>> def test()
>
> Should that not be
> def self.test()
> if you want to call it using
> MailSender.test()
>
> Colin

No. It is called from controller.

by
Reply all
Reply to author
Forward
0 new messages