Forum: Ruby on Rails Strange mailer behaviour in Rails 4.2

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Be07c8d0d6867fd9a0d525f7d17600e2?d=identicon&s=25 Damjan Rems (ther)
on 2015-02-17 10:56
The code inside test method doesn't get executed at all.

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

def test()
  should_die_here
  mail(
    :to => 'to@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
4c6bde00168d595053c09aac7e487f8e?d=identicon&s=25 Colin Law (Guest)
on 2015-02-17 11:08
(Received via mailing list)
On 17 February 2015 at 09:56, Damjan Rems <lists@ruby-forum.com> wrote:
> The code inside test method doesn't get executed at all.
>
> class MailSender < ActionMailer::Base
>   default :from => 'no.reply@some.where'
>
> def test()

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

Colin
Be07c8d0d6867fd9a0d525f7d17600e2?d=identicon&s=25 Damjan Rems (ther)
on 2015-02-17 11:11
Colin Law wrote in post #1168195:
> On 17 February 2015 at 09:56, Damjan Rems <lists@ruby-forum.com> wrote:
>> The code inside test method doesn't get executed at all.
>>
>> class MailSender < ActionMailer::Base
>>   default :from => 'no.reply@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
TheR
This topic is locked and can not be replied to.