Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

There was a problem

You must be a member of this account.

This project is archived and is in readonly mode.

ActionMailer does not return correctly to respond_to? with deliver_ prefix

#3431
require 'actionpack'
=> true
>> ActionMailer::Base.respond_to? 'deliver_sadasda'
NameError: uninitialized constant ActionMailer
    from (irb):2
>> require 'actionmailer'
=> true
>> ActionMailer::Base.respond_to? 'deliver_sadasda'
=> #<MatchData "deliver_sadasda" 1:"deliver" 2:"sadasda">

but should be false

Reported by grosser · October 27th, 2009 @ 04:19 PM

State: wontfix
Milestone: none
Assigned to: José Valim José Valim
Importance: none

Activity

  1. Cyril Mougel
    Cyril Mougel

    You right, it's because, ActionMailer::Base.respond_to? check only if this string can be used by ActionMailer. Not if it's implemented.

    October 27th, 2009 @ 09:43 PM

  2. Rohit Arondekar
    Rohit Arondekar
    • State changed from new to stale
    • Importance changed from to

    Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.

    October 6th, 2010 @ 06:36 AM

  3. grosser
    grosser
    • Tag changed from 2.3.4, actionmailer, rails to 2.3.9, actionmailer, rails

    still here in 2.3.9

    AccountMailer.respond_to?(:deliver_xxx)
     => #<MatchData "deliver_xxx" 1:"deliver" 2:"xxx">
    

    October 6th, 2010 @ 06:51 AM

  4. grosser
    grosser
    • Title changed from ActionMailer does not return correctly to respond_to? to ActionMailer does not return correctly to respond_to? with deliver_ prefix

    October 6th, 2010 @ 06:53 AM

  5. Rohit Arondekar
    Rohit Arondekar
    • State changed from stale to open
    • Assigned user set to Mikel Lindsaar

    grosser, can you work on a patch to fix this? Contributor guide: http://rails.lighthouseapp.com/projects/8994/sending-patches

    October 6th, 2010 @ 06:55 AM

  6. David Trasbo
    David Trasbo
    • Assigned user changed from Mikel Lindsaar to José Valim

    Here's a patch that applies to 2-3-stable right now.

    It doesn't just fix the issue, though. It also greatly simplifies and cleans up the way ActionMailer::Base.respond_to? and method_missing works by simply checking if we have a foo instance method if we do ActionMailer::Base.respond_to?(:deliver_foo) or :create_foo (which gives us the opportunity to remove a bunch of obsolete tests).

    October 6th, 2010 @ 08:03 PM

  7. David Trasbo
    David Trasbo

    Here's an improved version.

    October 7th, 2010 @ 07:00 PM

  8. Jeff Kreeftmeijer
    Jeff Kreeftmeijer
    • Tag changed from 2.3.9, actionmailer, rails to 2.3.9, actionmailer, patch, rails

    October 10th, 2010 @ 08:19 AM

  9. David Trasbo
    David Trasbo
    • Assigned user changed from José Valim to Santiago Pastorino

    October 10th, 2010 @ 04:26 PM

  10. Santiago Pastorino
    Santiago Pastorino
    • Assigned user changed from Santiago Pastorino to Mikel Lindsaar

    October 10th, 2010 @ 05:20 PM

  11. David Trasbo
    David Trasbo

    Santiago,

    I just want to point out that last time I assigned something to Mikel he didn't see it. Plus, this is not a technical change in terms of email - just a minor architectural change.

    October 10th, 2010 @ 05:57 PM

  12. José Valim
    José Valim
    • Assigned user changed from Mikel Lindsaar to José Valim

    The ticket was assigned to me, why change it in the first place? Please, have patience that I will apply them when I find some time.

    October 10th, 2010 @ 06:02 PM

  13. David Trasbo
    David Trasbo

    Sorry, José. I can see my intent was unclear, but I just wanted to take some load off your shoulders. You seem to have a lot to do at the moment. Again, sorry.

    October 10th, 2010 @ 06:08 PM

  14. José Valim
    José Valim
    • State changed from open to wontfix

    Instantiating an Action Mailer just to check if it responds to a given method does not look like a good idea to me, so I cannot apply the given patch. You could use instance_methods or public_instance_methods instead.

    This is a bug but I am marking it as won't fix since it is on 2-3-stable branch.

    October 11th, 2010 @ 11:37 PM

  15. David Trasbo
    David Trasbo

    So if I changed the patch to use instance_methods instead you wouldn't apply it anyway?

    October 12th, 2010 @ 03:35 PM

  16. José Valim
  17. David Trasbo
    David Trasbo

    "Could" is a bit vague, you know.

    October 12th, 2010 @ 03:43 PM

  18. bingbing