Ask for Help
“How can I turn off logging of email attachments in ActionMailer?”
You’re not the only person ever to ask that.
Actionmailer’s deliver method looks like this:
# File vendor/rails/actionmailer/lib/action_mailer/base.rb, line 473
473: def deliver!(mail = @mail)
474: raise "no mail object available for delivery!" unless mail
475: unless logger.nil?
476: logger.info "Sent mail to #{Array(recipients).join(', ')}"
477: logger.debug "n#{mail.encoded}"
478: end
479:
480: begin
481: __send__("perform_delivery_#{delivery_method}", mail) if perform_deliveries
482: rescue Exception => e # Net::SMTP errors or sendmail pipe errors
483: raise e if raise_delivery_errors
484: end
485:
486: return mail
487: end
And the actual delivery methods look like this:
# File vendor/rails/actionmailer/lib/action_mailer/base.rb, line 594 594: def perform_delivery_smtp(mail) 595: destinations = mail.destinations 596: mail.ready_to_send 597: sender = mail['return-path'] || mail.from 598: 599: Net::SMTP.start(smtp_settings[:address], smtp_settings[:port], smtp_settings[:domain], 600: smtp_settings[:user_name], smtp_settings[:password], smtp_settings[:authentication]) do |smtp| 601: smtp.sendmail(mail.encoded, sender, destinations) 602: end 603: end
If you compare lines 477 and 601, you will see that they both hook directly into the “encoded” method on the Tmail object. If you want to fix this, you’re going to have to patch (or monkeypathch) ActionMailer
“Why is Selenium running tests before Jelly has finished loading?”
The answer to this was that Webrat has a waiting period, and if you have a long load time you need to increase it.
try this to fix your selenium timeout problem (in your selenium_spec_helper.rb or equivalent):
Webrat.configure do |config| config.mode = :selenium config.selenium_browser_startup_timeout = 60 end
Interesting Things
- RVM hooks into Textmate.
You can set up Textmate to run tests using an RVM Ruby. See this, for example. - There are WWDC videos on iTunes if you have a Developer account.
- Garbage Collection: If you are using REE you need to pay attention to your garbage collection strategies. Even at low load levels it can make a difference in request time.
- Syslog-ng templates: If you have multiple servers, and you are using syslog-ng and Splnuk (you should be) you can format your syslog-ng log lines using templates.
- mail_safe: This is a gem that whitelists domains so all outbound email instead goes to you. Just install it and then
config.gem mail_safe
Of course, if you do this in production your emails won’t work. Use it wisely.
