Archive by Author

Rails 3 Performance

Great article on Rails 3 performance Rails 3 Performance – Not Good Enough

Rails and rake db:migrate in Production Mode

There are some inconsistencies when running rails server, rails console and rake db:migrate in production mode. There really should be a standard way to let the rails and rake commands know you want to execute them in production mode. Starting Rails Server in Production Mode Starting Rails Console in Production Mode rake db:migrate in Production [...]

Clearing All Rails Log Files with Rake Task

In order to clear all of your Rails log files development.log, production.log, server.log and test.log with a rake task, type: This is mainly useful while under development. Be careful with this as it will clear out your production.log file as well!

Building Custom XML Responses in Rails

Assume you have a CitiesController with just one action capital_city, which doesn’t need any of the RESTful actions. I set up a custom route for this one action. The capital_city action returns the xml like the following, for example: Here is what the entry in the routes.rb file looks like: Your controller may look something [...]

Bundle Install – missing mysql.h

If you’re seeing the following error: The way I was able to resolve it was to follow Boonedocks.net, since I’m also using MAMP for its MySQL Database instance. The only difference is that I already had MAMP 1.9.4 installed and so I had to download the MAMP_components_1.9.dmg which contains the mysql-5.1.44 source code. MAMP 1.9.4 [...]

Using lambda with named scopes in Rails 3

You can define an ActiveRelation named scope inside your model Address, for example, like so:

ActiveRecord destroy method

Once you destroy a record, the object becomes frozen. Call the frozen? method on the referenced object before and after calling destroy to see the difference. If you try to manipulate the object after the object is ‘frozen’, you’ll get a TypeError: can’t modify frozen hash

jQuery Makes Writing JavaScript Fun Again

Nick Pink attended the Silicon Valley HTML5 Users Group meeting recently and here are his notes which I am posting with his permission. Last night I went a meetup sponsored by the Silicon Valley HTML5 Users Group called “jQuery Makes Writing JavaScript Fun Again”. The speaker, Dr. Doris Chen of Microsoft, talked specifically about AJAX [...]

Ruby vs Python

Python vs. Ruby: A Battle to The Death

How to Create a Shorter Alias for Public DNS Hostname

After you’ve created your Amazon EC2 instance, set up Security Groups for ssh, set up your key pair, you will realize that your Public DNS for your EC2 instance is super long and very hard to remember. You also wish you could exclude having to type the "username@" prefix when you ssh to the server. [...]