views:

1821

answers:

2

I'd like to apply the action_mailer patch mentioned in this thread but I have never applied a patch before and I'm not sure how these work: https://rails.lighthouseapp.com/projects/8994/tickets/2263

My action mailer gem is here: /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/gems/actionmailer-2.3.2

I assume I need to go to that directory and run the patch command...something like this?

cd /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/gems/
wget https://rails.lighthouseapp.com/attachments/108548/0001-Fix-implicit-multipart-mailer-views-when-RAILS_ROOT.patch
patch < 0001-Fix-implicit-multipart-mailer-views-when-RAILS_ROOT.patch

One thing I'm not really clear on also is that the patch file refers to the "actionmailer" directory but mine is called "actionmailer-2.3.2"

+5  A: 

You typically don't want to patch the gem source itself. You probably will want to freeze the gems into ${RAILS_ROOT}/vendor/rails, and then apply the patch locally.

From your ${RAILS_ROOT} dir, dump all of your rails gems into vendor/rails

rake rails:freeze:gems

Apply the patch

  cd vendor/rails/ 
  patch -p1 < 0001-Fix-implicit-multipart-mailer-views-when-RAILS_ROOT.patch
rnicholson
Hi Micholson, thanks for the response. I agree you'd normally want to feeeze them, but due to the nature of this bug I'd like to have it fixed across all my rails apps (and hopefully not check a ton more files into version control). I might be able to get it just from what you've written though - after reading up no the -p option the directory problem makes more sense: http://linux.die.net/man/1/patch Cheers!
Brian Armstrong
+4  A: 

Micholson's answer above works. But to patch the actual gem for all rails apps (see my comment on his answer) this worked:

cd /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/gems/actionmailer-2.3.2
wget sudo wget https://rails.lighthouseapp.com/attachments/108548/0001-Fix-implicit-multipart-mailer-views-when-RAILS_ROOT.patch
sudo patch -p2 < 0001-Fix-implicit-multipart-mailer-views-when-RAILS_ROOT.patch
sudo rm 0001-Fix-implicit-multipart-mailer-views-when-RAILS_ROOT.patch

I found out you can also reverse a patch with -R if anything goes wrong. I'm surprised this process wasn't better documented somewhere. Hopefully this will turn up in Google searches for people new to patching like me.

Brian Armstrong
It turned up for me! And I thank you.
Matt Grande