If you are having problems installing the mysql gem on ubuntu, it requires the libmysqlclient-dev package to be installed.
This saves having to either compile mysql yourself or install the mysql-server package.
If you are having problems installing the mysql gem on ubuntu, it requires the libmysqlclient-dev package to be installed.
This saves having to either compile mysql yourself or install the mysql-server package.
Sometimes you don’t need to see all the sql queries that are being performed every time you reload a page in development.
Combining grep with tail you can achieve logging bliss, with just the right information you need for the job at hand.
Started GET "/pages/schools" for 127.0.0.1 at Wed Aug 10 18:52:48 +0100 2011
Processing by PagesController#show as HTML
Parameters: {"id"=>"schools"}
Cart Load (0.4ms) SELECT `carts`.* FROM `carts` WHERE `carts`.`id` = 2683403 AND (carts.purchased_at IS NULL) AND (carts.updated_at >= '2011-08-10 11:52:49') LIMIT 1
Page Load (0.5ms) SELECT `pages`.* FROM `pages` WHERE `pages`.`stub` = 'schools' AND (pageable_type IS NULL AND pageable_id IS NULL) LIMIT 1
Category Load (0.6ms) SELECT `categories`.* FROM `categories` WHERE `categories`.`hidden` = 0 AND (in_header = true) ORDER BY position ASC
SQL (0.4ms) SELECT COUNT(*) FROM `manufacturer_categories` WHERE (`manufacturer_categories`.category_id = 1)
ManufacturerCategory Load (0.8ms) SELECT `manufacturer_categories`.`id` AS t0_r0, `manufacturer_categories`.`manufacturer_id` AS t0_r1, `manufacturer_categories`.`category_id` AS t0_r2, `manufacturer_categories`.`created_at` AS t0_r3, `manufacturer_categories`.`updated_at` AS t0_r4, `manufacturers`.`id` AS t1_r0, `manufacturers`.`name` AS t1_r1, `manufacturers`.`stub` AS t1_r2, `manufacturers`.`created_at` AS t1_r3, `manufacturers`.`updated_at` AS t1_r4, `manufacturers`.`image_file_name` AS t1_r5, `manufacturers`.`image_content_type` AS t1_r6, `manufacturers`.`image_file_size` AS t1_r7, `manufacturers`.`image_updated_at` AS t1_r8, `manufacturers`.`position` AS t1_r9, `manufacturers`.`in_footer` AS t1_r10, `manufacturers`.`in_header` AS t1_r11, `categories`.`id` AS t2_r0, `categories`.`name` AS t2_r1, `categories`.`stub` AS t2_r2, `categories`.`created_at` AS t2_r3, `categories`.`updated_at` AS t2_r4, `categories`.`suffix` AS t2_r5, `categories`.`hidden` AS t2_r6, `categories`.`position` AS t2_r7, `categories`.`in_footer` AS t2_r8, `categories`.`in_header` AS t2_r9 FROM `manufacturer_categories` LEFT OUTER JOIN `manufacturers` ON `manufacturers`.`id` = `manufacturer_categories`.`manufacturer_id` LEFT OUTER JOIN `categories` ON `categories`.`id` = `manufacturer_categories`.`category_id` WHERE (`manufacturer_categories`.category_id = 1) AND (manufacturers.in_header = true and categories.in_header = true)
...
Rendered beta/shared/_footer.html.erb (58.5ms)
Rendered default/pages/schools.html.erb within layouts/application (868.7ms)
Completed 200 OK in 923ms (Views: 875.4ms | ActiveRecord: 5.9ms)
Watch your logs with the following:
tail -f log/development.log | grep -e Started -e Completed -e Processing -e ActionController
You will get the following output:
Started GET "/pages/schools" for 127.0.0.1 at Wed Aug 10 19:47:03 +0100 2011 Processing by PagesController#show as HTML Completed 200 OK in 547ms (Views: 482.9ms | ActiveRecord: 7.5ms)
Much easier to read!
Most of the time you will want to modify a string in your view with
or similar. This works fine until a method returns nil and you get a horrible exception that stops the page from loading.
For Example:
<%= product.manufacturer_name.downcase %>
If
returns nil; you will get the following exception:
undefined method `downcase' for nil:NilClass
It errors because nil doesn’t have the method downcase (which it should do). Now we could make sure that manufacturer_name always returns a string but this can become quite difficult if you are passing lots of strings around.
So how do you make sure that a string is always returned without altering the original method?
<%= "#{product.manufacturer_name}".downcase %>
The #{} syntax allows you to pass a nil object into it. In the example above you will end up with an empty string which has the downcase method available so even though it will do nothing it will no longer raise an exception.
You can try this yourself; Just replace
with
.
Lifehacker and ihnatko have shown how easy it is to create a desktop web app in Lion. Next job is to see how easy it is to make a native iPhone wrapper.
Give the pre alpha alpha stinkyink webapp a go. (only works on lion)
I’ve wanted this functionality for years and they have finally done it. It was so annoying having to cd in to the directory the previous tab was in every time you open a new one.
Certainly saves having to do hacks using AppleScript.
(This doesn’t work for new terminal windows only tabs.)

OS X Lion is now available and it is already the No. 1 top paid app in the App Store, I think Apple may have given it a helping hand because there is no way it’s already been downloaded more than all the other applications (Facetime, Garageband, iLife, …). To get started just search for Lion and click Buy App in the Mac App Store.
My iMac took around 30 minutes to upgrade and everything seems fine. I have a lot of custom apps installed and they are all ok, all my documents are intact and I’ve even got the same desktop background. At a first glance you wouldn’t know anything was different.
I am also running a development environment with RVM installed and it all still works. I’ve never been able to say that about os upgrades in the past. Your mac may seem a bit sluggish after you upgrade; this is due to spotlight indexing all your files and usually takes about an hour.
So to start it looks good for the new version of OS X and I hope to write future posts about some of its great features.
After spending 10 or so years reading other peoples blogs I think it’s about time I create one myself and give something back. I will rant/discuss about web development (especially rails), design and *cough* SEO.
Please sign up to my feed to keep updated with the latest content.