How can I make the Devise::Mailer a subclass of PostageApp?

benoror's Avatar

benoror

10 May, 2011 02:12 PM

  1. Support Staff 1 Posted by Tom Walsham on 10 May, 2011 03:34 PM

    Tom Walsham's Avatar

    Hey Ben,

    From what we have seen and heard from some of our users, it seems that the only way to have Devise work with PostageApp is to copy all of the Devise mailer code and put it into the PostageApp code so that it inherits from PostageApp instead of ActionMailer.

    Hope that helps!

  2. 2 Posted by benoror on 10 May, 2011 04:39 PM

    benoror's Avatar

    Hi Jon, thanks for your quick response!

    I've read the same thing but haven't seen exactly how its done, is it possible to override the whole devise_mailer.rb, or only the methods that are required? or should I edit the devise_mailer.rb directly? Thanks!

  3. Support Staff 3 Posted by Tom Walsham on 10 May, 2011 05:18 PM

    Tom Walsham's Avatar

    Hey Ben,

    Our theory is that you'll have to copy the mailers from the Devise code into your app as to override their mailers, and replace everything with PostageApp mailers.

    Please let me know if this works, I would love to document this for future reference.

    Thanks Ben!

  4. 4 Posted by benoror on 10 May, 2011 08:27 PM

    benoror's Avatar

    Ok, I copied ./vendor/gems/devise-1.0.11/app/models/devise_mailer.rb to ./app/models/devise_mailer.rb and just changed the header to:

    class DeviseMailer < PostageApp::Mailer

    I'll run some tests and post the results later, thanks!

  5. 5 Posted by benoror on 10 May, 2011 10:02 PM

    benoror's Avatar

    It seems to be working great now, thanks for your help Jon!

  6. Support Staff 6 Posted by Tom Walsham on 10 May, 2011 10:22 PM

    Tom Walsham's Avatar

    Ben,

    That's great news! Thank you for taking the time and effort to integrate Devise into PostageApp. Please let me know if you have any further questions or comments - I will be sure to document your solution into our documents.

    Thanks again!

  7. 7 Posted by Typhoon on 27 May, 2011 04:52 PM

    Typhoon's Avatar

    Hi @benoror, can you elaborate a little bit -- I'm a little confused, isn't devise_mailer.rb in a mailer directory?

    Also, did you need to change anything in the config/initializer/devise.rb file?

  8. 8 Posted by benoror on 30 May, 2011 04:37 PM

    benoror's Avatar

    I'm using Rails 3, the mailer is located at:

    app/mailers/my_devise.rb

    The mailer is a subclass of Devise:

    class MyDevise < Devise::Mailer

    And devise is configured to use that mailer instead of the default:

    cat config/initializers/devise.rb | grep config.mailer

    config.mailer = "MyDevise"

  9. 9 Posted by Typhoon on 11 Jun, 2011 04:56 AM

    Typhoon's Avatar

    How is this inheriting from the postageapp class if it is using Devise::Mailer?

  10. 10 Posted by fosrias on 12 Jun, 2011 06:54 PM

    fosrias's Avatar

    @Typhoon

    I believe he meant to say:

    class MyDevise < PostageApp::Mailer.

    At least doing it that way works just fine for me.

  11. Support Staff 11 Posted by Tom Walsham on 12 Jun, 2011 10:46 PM

    Tom Walsham's Avatar

    @fosrias: Thanks for helping us clear this up!.

    Tim, let us know if you if it works for you, and hopefully we can fully document this entire process to save time in the future.

  12. 12 Posted by fosrias on 12 Jun, 2011 10:52 PM

    fosrias's Avatar

    @Jon Lim

    If you can attach a sample boilerplate for documentation, I will write something up for you since I just converted as devise app to postage app and it was easy, apart from figuring a few simple things out that I could give as examples.

    Just show me a format and I will send you something to look at.

  13. Support Staff 13 Posted by Tom Walsham on 12 Jun, 2011 11:34 PM

    Tom Walsham's Avatar

    @fosrias: That would be amazing. I will be in touch via email to work out the details, we really appreciate that!

  14. 14 Posted by Typhoon on 25 Jun, 2011 03:36 PM

    Typhoon's Avatar

    I seem to be having a problem running this on heroku thin production server (ditto in local):

    allyforce/app/mailers/devise_mailer.rb:1: superclass mismatch for class Mailer (TypeError)

    1 class Devise::Mailer < PostageApp::Mailer

    This was working fine when running locally on webrat -- but now that it is up on heroku, it doesn't work....why is it not recognizing postageapp as the right class type?

  15. 15 Posted by fosrias on 25 Jun, 2011 04:52 PM

    fosrias's Avatar

    You can't do:

    Devise::Mailer < PostageApp::Mailer since it is an invalid inheritiance scenario since it is directly a subclass of ActionMailer.

    http://jackndempsey.blogspot.com/2008/06/superclass-mismatch.html

    Did you read above? Use:

    MyMailer < PostageApp:Mailer

    copy deviser mailer methods, etc.

    end

    and then in devise.rb set:

    config.mailer = "MyMailer"

  16. 16 Posted by Typhoon on 25 Jun, 2011 08:01 PM

    Typhoon's Avatar

    Yeah, I tried that approach and it didn't work. Someone else used this
    devise mailer and it works locally. Why does it work locally but not
    with thin?

  17. 17 Posted by fosrias on 25 Jun, 2011 08:30 PM

    fosrias's Avatar

    Not sure why it does not work with thin, I am using it remotely on passenger and it works like a charm.

    BTW, what does "it didn't work" mean?

  18. 18 Posted by Typhoon on 26 Jun, 2011 01:17 AM

    Typhoon's Avatar

    @fosrias -- I looked at my code, I am doing this already, this is my code please let me know, thanks...driving me nuts...

    app/mailer/new_devise_mailer.rb

    1 #class NewDeviseMailer < Devise::Mailer
    2 class NewDeviseMailer < PostageApp::Mailer
    
    11   # config.mailer = "Devise::Mailer"
    12    config.mailer = "NewDeviseMailer"
    

    By doesn't work, I get that inheritance error superclass mismatch.....

  19. 19 Posted by Typhoon on 26 Jun, 2011 01:21 AM

    Typhoon's Avatar

    I think I figured it out...I now get a separate,, unrelated error:

     dependencies.rb:239:in `require': no such file to load -- dispatcher (LoadError)
    

    thanks....

  20. Support Staff 20 Posted by Tom Walsham on 06 Jul, 2011 06:14 PM

    Tom Walsham's Avatar

    Hey guys,

    Just wanted to tell you that thanks to Mark Foster (fosrias), we now have Devise integration instructions in the documentation. It's at the bottom of the page.

    Please help us out by giving us feedback - it would be much appreciated! You can direct your feedback to jon[at]postageapp.com.

    Thanks!

  21. Tom Walsham closed this discussion on 06 Jul, 2011 06:14 PM.

  22. fosrias re-opened this discussion on 06 Jul, 2011 06:17 PM

  23. 21 Posted by fosrias on 06 Jul, 2011 06:17 PM

    fosrias's Avatar

    Hi Jon:

    BTW, I got devise to modularize their code to make the implementation even
    simpler and non-brittle. I have not done it yet, but will pass along the
    updated instructions once I get back in my codebase and make sure it is all
    working.

    Mark

  24. Support Staff 22 Posted by Tom Walsham on 06 Jul, 2011 06:18 PM

    Tom Walsham's Avatar

    Mark,

    That is fantastic. You are a gentleman and a scholar, really appreciate your efforts!

Discussions are closed to public comments.
If you need help with PostageApp please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

18 Sep, 2017 04:58 PM
17 Sep, 2017 09:26 PM
12 Sep, 2017 04:49 PM
12 Sep, 2017 08:45 AM
11 Sep, 2017 05:41 AM