The blog has moved to http://jessehouse.com/ ... Many google searches point here so I am leaving it operational, but there will be no new posts.

Tuesday, March 23, 2010

sorting rails view with will_paginate plugin

This solution for sorting data on rails index actions does NOT use ajax. Sometimes sorting with ajax is nice but often it is not actually as user friendly; breaking the browser back button, etc...

Disclaimer 1: this code is probably using all kinds of ruby anti-patterns :) - but it is a very simple implementation and so I just went with it...

Disclaimer 2: the title of the post might be a little miss leading as you can use this with or without the will_paginate plugin. In my case I am using it with the will_paginate plugin - and I highly recommend it!

put this file in your rails lib directory /lib/sort_index.rb

in your controller code, set up the SortIndex::Config (you can have more than one if you have multiple actions that need to support sorting

then in your view code render your table headers using the sort object

Does not support the following:
  • additional attributes on the anchor tags
  • additional attributes on the table header tags
  • additional query string parameters - might add this later, would be nice for search results

Monday, March 15, 2010

Digg style css for will_paginate plugin

Just started using the will_paginate plugin for my rails application. I wanted a Flickr or Digg style applied to the paging controls, did not find anything that came 'out 0f the box'. After a few google searches I came across this link which had an example - apparently from an older version of the README file.

here is that css for reference

.

Thursday, March 11, 2010

exclude .svn results with egrep recursive search

The exclude-dir option works nicely, I was previously was using --exclude and it would include some sub-dir .svn files
egrep --exclude-dir=\.svn -r -n {search-criteria} {directory}
i.e. find all TODO comments in the current directory and all sub directories
egrep --exclude-dir=\.svn -r -n TODO .

Found this in the comments on this post - http://antoniolorusso.com/2008/05/12/grep-excluding-svn-dirs/

.

Friday, March 5, 2010

cut back on the blog reading

I had 200+ subscriptions in my rss reader - way too many
I just cut it back to a short list. No doubt the list will start to grow again...




Thursday, March 4, 2010

"Impossible to connect to file" error opening dBase file with open office on ubuntu

Turns out the ubuntu distribution of Open Office does not include the 'Database' product by default, it tries to open the file with the spread sheet program which can not handle it and errors with "Impossible to connect to file". The fix is to install the database product
System -> Administration -> Synaptic Package Manager
install openoffice.org-base
After installing you should see the 'Open Office.org Database' under Applications menu



Found the answer from this post.