Forum: Ruby on Rails Missing text/html content in production (but not development

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.
4ef16ff17bbfb331c657d584ea0dc135?d=identicon&s=25 Reuven M. Lerner (Guest)
on 2006-02-19 04:26
(Received via mailing list)
Hi, everyone.  I'm getting a production server ready for a site I'm
working on, and I've been a bit stumped by a difference between the
development server (running under Webrick) and the production server
(running under lighttpd).

Here's the scenario: I'm working on a variation of an e-commerce
system.  When someone finalizes an order with our system, we not only
want to send them a confirmation e-mail message, but also a JPEG image
with a mailing label.  The mailing label has been modified from an
original template using RMagick.  So the bottom line is that I want to
send the user an e-mail message with two different parts -- one with a
MIME type of text/html, and the other with a MIME type of image/jpeg.

The problem is that everything works perfectly under Webrick: I get the
text/html content, I get the image/jpeg content, and it looks just
swell.  But when the same code (checked out from CVS, and double-checked
that they're running identical code) runs under lighttpd, the text/html
content is completely missing.  Looking at the source of the e-mail
shows that the text/html portion of the message is completely missing,
not just hiding or mangled.  The image is always there, without any
problems whatsoever.

I've gone around and around with this, but can't figure out what's going
wrong.  Can anyone suggest anything?

Here's the mail-generation method that's being invoked (from another,
public method) in my controller:

      private
      def generate_mailing_label_email
        label = create_mailing_label(@order)
        OrderMailer::deliver_mailing_label_message(@order, @person,
label)
      end

And here is the method that's defined in OrderMailer <
ActionMailer::Base:

      def mailing_label_message(order, person, label)
        @recipients = person.email_address
        @subject = "Mailing label for MySite order ##{order.id}"
        @from = "CustomerService@MySite.com"
        @content_type = 'text/html'

        @body[:order] = order
        @body[:person] = person

        attachment :content_type => 'image/jpeg', :body => label

    end


mailing_label_message.rhtml is a simple bit of HTML, with one ERb call
in it -- an invocation of link_to.

By the way, when I run the production server under WEBrick, I get the
same output as with lighttpd. So this seems to be a problem with the
production server.  I don't see any obvious permission issues, and I'm
certainly not getting any error logged to production.log (or anywhere
else I can see).

I'm guessing that I have either discovered a weird bug, that my system
is configured incorrectly, or that I've missed an obvious point about
sending e-mail with attachments.  (In reverse order of probabilities, I
would say.)  Whatever it is, please enlighten me!

Thanks,

Reuven
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-02-19 04:41
(Received via mailing list)
On Sat, 2006-02-18 at 22:25 -0500, Reuven M. Lerner wrote:
> send the user an e-mail message with two different parts -- one with a
>
>           end
>
> else I can see).
>
> I'm guessing that I have either discovered a weird bug, that my system
> is configured incorrectly, or that I've missed an obvious point about
> sending e-mail with attachments.  (In reverse order of probabilities,
> I would say.)  Whatever it is, please enlighten me!
----
don't know if this is your first venture into production mode but I
definitely noticed prolonged effects of session caching in production
mode which manifest differently than development mode when you are
adjusting/changing controller code.

What I do before I panic is to kill the httpd service (I don't use
lighttpd) and clear out the sessions (rm /tmp/ruby.sess*) and then
restart the httpd service and try again.

Other than that, I am still in learning mode and probably can't help.

PS...love the articles

Craig
4ef16ff17bbfb331c657d584ea0dc135?d=identicon&s=25 Reuven M. Lerner (Guest)
on 2006-02-19 04:47
(Received via mailing list)
Hi, Craig.  You wrote:
> don't know if this is your first venture into production mode but I
> definitely noticed prolonged effects of session caching in production
> mode which manifest differently than development mode when you are
> adjusting/changing controller code.
>
> What I do before I panic is to kill the httpd service (I don't use
> lighttpd) and clear out the sessions (rm /tmp/ruby.sess*) and then
> restart the httpd service and try again.
>
A good suggestion -- but I'm already killing lighttpd and dispatch.fcgi,
then restarting them, when I test my code.  Also, I wrapped the code
that sends a mailing label into its own publicly accessible URL, just so
that I could test it without putting through a full order -- and I had
the same problems when invoking that URL from lynx, without any cached
baggage to speak of.

I removed existing sessions (after killing, and before restarting,
lighttpd) just to see if you were right -- and unfortunately, this
didn't have any effect.
> PS...love the articles
Thanks!

Reuven
This topic is locked and can not be replied to.