will_paginate is the de facto Rails paging plugin, and with good reason – it’s solid, fast, and reliable. Everyone I know uses it, but a lot of people don’t use it to its full power. I recently discovered some very cool functionality it includes – the WillPaginate::Collection class can be used as a custom paginator [...]
Category Archives: Rails
Eight tips for getting the most out of your Rails app
Rails does an awful lot to optimize page generation, but there are a number of hacks, tweaks, and usage patterns you should be using to get the most out of your app. Configuration tweaks There’s a lot of the Rails stack that’s written in Ruby, which is great – it’s portable, it’s flexible, it works [...]
When you have to store user passwords…
Today we got word of yet-another-database-hack-with-plaintext-passwords. This time, it’s RockYou, purveyor of many of those Facebook and Myspace apps you use. Oops. Every time this comes up, everyone says “How naive! They should have been using salted hashed passwords!” This is true in any case where you don’t need to use the password again on [...]
Fine tuning your garbage collector
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 [...]
Monitoring Rails: Getting instant monitoring alerts
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 [...]
Mass inserting data in Rails without killing your performance
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 [...]
Re: Simple RoR+MySQL optimization
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?
Powerful, easy, DRY, multi-format REST APIs
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 [...]
Hold the RJS, please.
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 [...]