The Parallel Gem and PostgreSQL (oh, and rails.)

Some Preface An app I’m working on has a rake that that basically gathers data from the web.  Doing things serially is really REALLY slow and to get around this I started using the (fantastic) parallel gem by Michael Grosser. This gem is great — it’s simple to use and in something like 3 minutes […]

Migrating Data From MySQL to PostgreSQL

A Little Back Story… Migrating from MySQL to PostgreSQL is not as straight forward as it sounds.  As you may or may not know, MySQL’s ‘mysqldump’ utility comes with a “compatible” option where you can specific “postgresql” but the catch is this:  the resulting SQL is not properly escaped and will need it’s data types […]

Sunspot ‘keywords’ vs ‘fulltext’

THEY ARE THE SAME DAMN THING. keywords (keywords, options = {}, &block) Alias for fulltext Nothing to see here… but ambiguously named aliases. 🙂

How to Use the friendly_id gem w/ STI Models

To start off, the friendly_id gem allows your models to have “slugs” which ultimately help when you want your urls to appear more descriptive. For example instead of  you will get something like: . It’s better for SEO and IMO provides a better experience for situations where someone copies a link and sends […]

Sorting an Array of Hashes via a Hash Key

My use case for this is that i have a rails app using STI.  I’ve got an array of results from all of my inheriting models and i’d like to sort them ALL based on a common attribute they share — a zip code. Here is a RIDICULOUSLY simple way to use Ruby to sort […]

Flash Messages & Twitter’s Bootstrap CSS Framework

I’m using Twitter’s Bootstrap CSS framework and it’s pretty nice.  One of the cool bundled features of the framework is that they provide classes for displaying what rails hackers know as Flash messages.  The problem here is that Twitter has named them different from what Rails people traditionally use so you cannot just drop in […]

Emit a Comma Separated List of Links From an Array in Your Rails View

Yeah, this post has the WORST title ever, but i tried to litter it with keywords so people struggling can find it easily. When messing with my Rails views I find that pretty commonly I’m dealing with lists of things i need to use link_to on AND split them with a comma.  Here’s a super […]

Some Arel Notes

I talked to a gentleman in #rubyonrails on IRC who goes by the name of codepoet_ about Rails3 and Arel for a while today and he linked me to what is somewhat of an Arel cheat sheet he created. With his permission I am reposting this as a reference tool for myself.  Hopefully someone else […]

Woes of The Jeweler Gem & .gitconfig

I wanted to play around with creating my own gems so today I decided to try the jeweler gem. Install went fine: io@love:~$ sudo gem install jeweler Successfully installed jeweler-1.4.0 1 gem installed Installing ri documentation for jeweler-1.4.0… Installing RDoc documentation for jeweler-1.4.0… But when i attempted to create “the perfect gem” I ran into […]

Finding, and Ordering Through an Association

I ran into an issue today.  I have a Blog model that has_many feed_entries. In plain english, I needed a list of blogs ordered by most recently updated feed. My models look like this: blog.rb has_many :feed_entries feed_entry.rb belongs_to :blog The query that makes it possible: Blog.find(:all, :include => :feed_entries, :order => ‘feed_entries.published_at DESC’) :include […]