Capistrano failure to deploy

Had an issue a while ago where running the capistrano deploy common would sorta run capistrano but always got the following error.

The deploy has failed with an error: No live threads left. Deadlock?

The quick and easy answer is to make sure to prefix the cap command with bundle exec. So it should look like

bundle exec cap production deploy

There is some strange behavior here that I have not found the cause of yet. Something about how bundler executes ruby scripts. So just a heads up.

Adding Attachments with ActionMailer

Well recently I had the fun task of using Ruby on Rails' ActionMailer to create some automated emails to send out to users. At some point it was decided to attach the original email we received from the user to the notification email we were sending out to the user.

Now you would think that using the attachments method provided by ActionMailer would make it a easy as just giving it the file you wanted to add. Turns out it's like that for Ruby on Rails 3, not for 2.

The most infuriating thing was that if you use the attachments method then the method you called attachments from will not render the default view template it would normally. This means you have to explicitly call the render method.

Instead of putting it out all nicely I'll just link to a blog post from ELCtech.com that explains it well. http://www.elctech.com/ -- [ActionMailer] Multipart emails with attachments