* [sup-talk] Hook, again
@ 2009-09-26 18:09 Guillaume Quintard
2009-09-27 1:27 ` William Morgan
0 siblings, 1 reply; 2+ messages in thread
From: Guillaume Quintard @ 2009-09-26 18:09 UTC (permalink / raw)
Sorry to come back again with that issue, but I'm having trouble with
the reply-from hook. Here's what I have:
message.recipients.each {
|person|
if (person.email =~ /addr at site.com/) != nil
Person.from_address "Foo <bar at site.org>"
end
}
But it doesn't seem to work.
If I reply to a mail addressed to addr at site.com, the log says nothing, but the from field isn't changed.
If I reply to any other mail, le log complains I didn't return a Person
And if I just put Person.from_address "Foo <addr at site.org>" in the
hook, the from field is correctly changed.
I'm a bit lost on that one (still not knowing alot of ruby doesn't help
I must say). Am I missing the obvious here?
Cheers.
--
Guillaume
^ permalink raw reply [flat|nested] 2+ messages in thread
* [sup-talk] Hook, again
2009-09-26 18:09 [sup-talk] Hook, again Guillaume Quintard
@ 2009-09-27 1:27 ` William Morgan
0 siblings, 0 replies; 2+ messages in thread
From: William Morgan @ 2009-09-27 1:27 UTC (permalink / raw)
Reformatted excerpts from Guillaume Quintard's message of 2009-09-26:
> message.recipients.each {
> |person|
> if (person.email =~ /addr at site.com/) != nil
> Person.from_address "Foo <bar at site.org>"
> end
> }
The problem is that #each returns the original array, i.e.
message.recipients. Your Person object is getting constructed and then
forgotten.
Try:
if messages.recipients.any? { |p| p.email =~ /addr at site\.com/ }
Person.from_address "Foo <bar at site.org>"
end
--
William <wmorgan-sup at masanjin.net>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-09-27 1:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-26 18:09 [sup-talk] Hook, again Guillaume Quintard
2009-09-27 1:27 ` William Morgan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox