devise_invitable icon indicating copy to clipboard operation
devise_invitable copied to clipboard

invitation_instructions undefined

Open bliaxiong opened this issue 10 years ago • 10 comments
trafficstars

Upgrading from Rails 3.2 to 4.1.8 and I'm getting:

undefined method `invitation_instructions' for Devise::Mailer:Class

But when I go into the terminal, it seems to be included in the class:

jruby-1.7.15 :003 > Devise::Mailer.respond_to?(:invitation_instructions) => true

Not entirely sure why its resulting in an undefined method error.

Environment: Devise 3.4.1 Devise_invitable 1.4.0 JRuby 1.7.15 Mac OS X

Work around, I have to put the invitation_instructions method into the Devise::Mailer class.

The issue seems to happen when the mailer runs in the background with Torquebox 3.1.1.

Any help/suggestions greatly appreciated.

bliaxiong avatar Dec 11 '14 22:12 bliaxiong

Have changed the devise::mailer class?

scambra avatar Dec 19 '14 08:12 scambra

I don't know why it doesn't work correctly when when backgrounded by Torquebox; it works correctly when if the mailer runs normally. I don't know if its a Rails 4 issue or something else. I've moved on but will need to circle back and find out whats causing the problem.

bliaxiong avatar Dec 19 '14 16:12 bliaxiong

Maybe torquebox is not initializing every gem, maybe you could add some require, I'm sorry not being more specific, I don't know torquebox.

scambra avatar Dec 22 '14 11:12 scambra

I had a similar problem (rails 4.0.13, sidekiq, custom devise mailer). I could isolate the error to devise_invitable upgrade from 1.3.5 to 1.3.6, and more specifically to commit 9d0b154. I solved it by adding Devise::Mailer.send :include, DeviseInvitable::Mailer to the beginning of my custom devise mailer file. Will change to devise-async in the near future.

luisico avatar Jan 28 '15 21:01 luisico

Will try that out.Thanks @luisico !

bliaxiong avatar Jan 28 '15 21:01 bliaxiong

I don't understand why you need that, @luisico I think it should work using Devise.mailer instead of Devise::Mailer. Have you changed mailer in devise initializer?

scambra avatar Jan 30 '15 12:01 scambra

Yes, I have a custom mailer for sending mails in the background with sidekiq. The code is the same as in the last gist at https://github.com/mperham/sidekiq/wiki/Devise. I guess the changes you introduced in 9d0b154 make DeviseInvitable::Mailer available in Devise.mailer (my custom mailer), but not in Devise::Mailer, which my custom mailer calls internally. In the near future I plan to use devise-async and not a custom mailer.

luisico avatar Feb 02 '15 17:02 luisico

Thanks for that tid bit. I'll look into implementing that when I get a chance.

On Mon, Feb 2, 2015 at 11:35 AM, Luis Gracia [email protected] wrote:

Yes, I have a custom mailer for sending mails in the background with sidekiq. The code is the same as in the last gist at https://github.com/mperham/sidekiq/wiki/Devise. I guess the changes you introduced in 9d0b154 https://github.com/scambra/devise_invitable/commit/9d0b154f7a40bc052198c4845fb0043ce8c153ce make DeviseInvitable::Mailer available in Devise.mailer (my custom mailer), but not in Devise::Mailer, which my custom mailer calls internally. In the near future I plan to use devise-async and not a custom mailer.

— Reply to this email directly or view it on GitHub https://github.com/scambra/devise_invitable/issues/524#issuecomment-72500122 .

Thanks!

Blia Xiong [email protected]

bliaxiong avatar Feb 02 '15 18:02 bliaxiong

Yes, that's right. Devise.mailer is usually used to override devise mailer with a custom one which inherits from Devise::Mailer, include DeviseInvitable::Mailer in Devise::Mailer doesn't work for those custom mailers.

Maybe I can include DeviseInvitable::Mailer into Devise.mailer and Devise::Mailer, hopefully it will work for both cases, but I need to test it doesn't break custom mailers

scambra avatar Feb 03 '15 09:02 scambra

Thanks!

On Tue, Feb 3, 2015 at 3:15 AM, Sergio Cambra [email protected] wrote:

Yes, that's right. Devise.mailer is usually used to override devise mailer with a custom one which inherits from Devise::Mailer, include DeviseInvitable::Mailer in Devise::Mailer doesn't work for those custom mailers.

Maybe I can include DeviseInvitable::Mailer into Devise.mailer and Devise::Mailer, hopefully it will work for both cases, but I need to test it doesn't break custom mailers

— Reply to this email directly or view it on GitHub https://github.com/scambra/devise_invitable/issues/524#issuecomment-72617352 .

Thanks!

Blia Xiong [email protected]

bliaxiong avatar Feb 03 '15 15:02 bliaxiong