Rails 3 Config Auto Load Paths in Application.rb

In Rails 3 files in lib/ are no longer loaded by default. It’s a snap to auto load these classes by adding the following line to config/application.rb

    config.autoload_paths += %W(#{config.root}/lib)

This is commented out around line 16. Either replace it or uncomment it out to reflect the location where your lib classes are located.

Have Git Email Committers After Pushes

You need a Mail Transfer Agent MTA on the server. The easiest way is to install Sendmail, which Git uses by default.

apt-get install sendmail

Remember that /etc/hosts file needs the ip address to map to the domain name your sending mail from

# vim /etc/hosts
127.0.0.1     localhost localhost.localdomain
207.136.202.87    wwwexample.com
 

Sendmail has a tendency to hang when sending mail otherwise. To test sendmail

sendmail email@example.com
this is a test
how are you today world?
.

The period on a line by itself denotes end of message and will terminate the prompt and deliver the message.

Now you need to configure Git to send email after it receives a “push” from a committer. You can add email addresses, or you can set up a mailing list to email all members. Either way, you accomplish this with the following command, just remember to cd into the git repository.

git config --add hooks.mailinglist "mailinglist@example.com"

Next you need to activate the post-receive hook, located in the hooks directory of your repository.

cp post-receive.sample post-receive

And uncomment the last line, which uses sendmail to deliver the commit message

# uncomment the last line but keep the period "."
. /usr/share/doc/git-core/contrib/hooks/post-receive-email

All done. Now just make some changes to your source code, add and commit them and you should receive an email with all the details!

Install do_mysql Ruby Gem on Mac OS X

I ran into the same problem when installing mysql gem for Rails development. This fix worked for me http://seanbehan.com/programming/fixing-mysql-for-rails-2-2-development-on-mac-os-x/

The same thing works with the data objects gem. Just specify the path the mysql config that it’s using and the gem should install just fine.

gem install do_mysql -- --with-mysql-config=/opt/local/lib/mysql5/bin/mysql_config