If you’re familiar with Ruby at all, you know that it can be a little wacky when it comes to memory usage. Most of us have observed a Mongrel/Passenger instance that starts out small and then grows by leaps and bounds, eventually settling on some uncomfortably high number. We’re going to fix that with Ruby [...]
I do a lot of memory and garbage analysis on my Rails apps, and in upgrading to Rails 2.3, I discovered a practical use for the new Rails Metal middleware. Dumping memory stats to my log was just sorta unreadable in a practical scenario, and was more or less entirely unusable in production. Fortunately, Metal [...]
Monitoring is big. Having an automated daemon watch your stuff and make sure it’s running properly can let you sleep at night, knowing that if something blows up, there’s an ever-watchful guardian ready to wake you up so you can fix it. There are a number of monitoring solutions that are popular these days, such [...]
Ruby’s awesome. It has sweet, concise syntax that makes for clean, readable code. One of these constructs is the trailing condition. In most languages where you might have to write something like: Ruby will let you clean that up with: This works just nearly all the time, but I ran into an odd problem today, [...]
Mass inserting is one of those operations that isn’t really well-supported by ActiveRecord, but which has to be done nonethless. You might say, “Well hey, I’ll just run a loop and create a bunch of AR objects, no sweat”. That’ll work, but if speed is a factor, it might not be your best option. ActiveRecord [...]
I recently ran across a rather bare post espousing some generic “optimization” techniques for Rails apps. It offered no education, no explanation, no benchmarks. So, I thought, why not put those claims to the test?
Rails’ baked-in REST support is great. Build your app right, and you can expose a programmatic interface to your users for free. That said, many times providing views in non-HTML formats tends to be bulky and unwieldy. You end up with either very brittle representations of your data, or extremely bulky respond_to blocks in your [...]
Rails does a great job at many things, but one of the most consistent stumbling blocks I see in #rubyonrails is RJS. It complicates many things that just don’t need to be that complex, especially when using a Javascript helper library like Prototype or jQuery. Keep things simple! One little helper, and your AJAX requests [...]
attachment_fu is fantastic, but it’s a bit limited for some purposes. Ever wanted to upload data from a URL instead of making people upload files? It’s a common problem! Presume that we have a model named Image, which is our target for attachment_fu. Adding URL upload capability is surprisingly simple: There you go. All you [...]
Ever wanted to do IM from Rails? xmpp4r-simple makes it really easy to talk to Jabber clients (such as Google Talk users) from Ruby, but it’s not quite a cut-and-dried solution for your Rails apps. Fortunately, there’s Jabberish. Jabberish is a DRb-backed Jabber client designed for use in multi-server Rails apps. Just drop in the [...]