Strange mailer behaviour in Rails 4.2


#1

The code inside test method doesn’t get executed at all.

class MailSender < ActionMailer::Base
default :from => ‘removed_email_address@domain.invalid’

def test()
should_die_here
mail(
:to => ‘removed_email_address@domain.invalid’,
: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


#2

On 17 February 2015 at 09:56, Damjan R. removed_email_address@domain.invalid wrote:

The code inside test method doesn’t get executed at all.

class MailSender < ActionMailer::Base
default :from => ‘removed_email_address@domain.invalid’

def test()

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

Colin


#3

Colin L. wrote in post #1168195:

On 17 February 2015 at 09:56, Damjan R. removed_email_address@domain.invalid wrote:

The code inside test method doesn’t get executed at all.

class MailSender < ActionMailer::Base
default :from => ‘removed_email_address@domain.invalid’

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
TheR