A Better Way to Page

Well, for some values of "better." Rails has built-in pagination. This is convenient. It was also clear to me even on cursory inspection that it wasn't being terribly sophisticated about how it was doing things. That's OK - if you're presenting 100 rows in pages of 20, who cares how optimized the code is?

But sometimes you're presenting hundreds of thousands of rows, so it's nice to have a better solution, at the cost of a bit more work. Part of being a developer is knowing when it's smart to trade off more work against some other value (like saving those CPU cycles). Enter I Will Paginate which showed up on Err The Blog this morning. Using nicked PHP code, it uses a more scalable technique that should work better in most situation.

Is this the end of the pagination debate? Nope. If you know exactly what your database backend is, you can probably do even better, provided you don't mind coupling the database implementation decision closely to your code (and giving up portability). Knowing whether that's a smart thing to do is another one of those reasons that developers get paid to actually think.

Over my Head But I Hope It Doesn’t Stay There

Just released: version 1.2 of Rails Engines . Near as I can figure it out so far, engines are a way to share components among your projects, which seems like a good thing, only they appear to have been controversial in the past. Anyhow, bookmarked so I can come back to this when I reach a greater level of Rails understanding and can figure out whether this is a Good Thing or not.

Yummy Deployment Goodness

OK, so very few people are going to learn about the release of Capistrano 1.4.0 from me rather than from some other source. But I'm going to blog it anyhow, because I have ambitions to some day have this be as good a news source for my new community as Larkware is for my old one, and I have to start somewhere.

Anyhow, if you're deploying Rails applications from one server to another, you need this. It can also do a lot more than that, and some day when I get through a stack of other stuff I will explore it properly. Meanwhile it's off to run sudo gem install capistrano on a couple of machines to get them to update.

This Came in Handy Tonight

I'm still moving along on the LarkWrite code, and one of tonight's tasks was to move some hard-coded strings out of views and into an external configuration file. After all, if I'm going to make this code available to people, eventually they're going to want to set their own titles and copyright strings, at least. I'd thought about a single-record database table, but using YAML for this seemed like a more sensible idea. The answer (or at least what seems to be a reasonably plausible answer) turned up over at Code Snippets - reading the entire YAML file in one fell swoop as part of environment.rb:

APP_CONFIG = YAML::load(File.open("#{RAILS_ROOT}/config/appconfig.yml"))

While I'm cautious about "programming by search engine," this looks like pretty much the solution I was hunting for in the first place.

Just ‘Cause I Keep Needing It

RUBY-DOC.ORG is loaded with online searchable Ruby documentation. This is very useful when you're using a Web framework based on a language that you don't really know yet.

To Conference or Not to Conference?

Now that I'm moving into a new universe of development, I need to start thinking seriously about the conference circuit again. RailsConf is coming up in May in the relatively-close venue of Portland, and Amy Hoy has a roundup of some smaller Ruby conferences on her weblog today.

Certainly conferences were an important part of my personal branding strategy when I got started in coding for the Microsoft platform - but that was speaking at conferences, not just attending them. I do not think I'll be in a position to pitch myself as a speaker until very late this year, or early next. So I need to think hard about the costs of attendance. Even RailsConf would cost a couple of grand to get to, between the $800 registration, travel and hotel, and 4-5 days that I can't bill at my current rate. That's a fairly significant hit. Balance against that some incremental amount of networking and learning - incremental in that I can otherwise do some pretty decent networking and learning over the Internet.

Right now I'm inclined to think that conference attendance falls into the "luxury" category for me, and that I'd be better served by putting the time into polishing my coding skills.

Ask and Ye Shall Receive

A few days ago I speculated that it might be time to open a support group or mailing list for developers trying to rise up and throw off the chains of Microsoft. Fortunately for me, the lazyweb has come to my rescue here. The guys over at Softies on Rails just announced the opening of a new forum for people making the journey. See you there!

Another Layer on Top of Rails

Streamlined "is a framework, on top of Rails, that allows you to quickly generate interfaces for your ActiveRecord models. It started as a way to generate Administrative backends, but has become more general purpose over time." Looks way classier than scaffolding, but it's also having a bit of code ferment right now as it switches from being a generator to being a plugin. Another one to dig in when I get the chance. (via CodeHappy)

Amazon S3 in Ruby

Mike Clark has another interesting post today, Getting Started with the Amazon S3 Library for Ruby , exploring yet another spiffy Ruby library. I continue to be impressed with some of the things that people have wrapped up in small amounts of Ruby code - and happy that I don't have to cart them all around with me in some super-giant-mega framework when I don't need them.

Setting up Eclipse for Rails

There's a good-looking set of instructions over at My Preferred Rails Development Environment (via dzone). In it, Yehuda Katz walks through the basic install steps for Eclipse, and then configures it with a set of plugins to speed Rails development.

I'm not going down this road myself at the moment, though. When learning a new language, I prefer to stick fairly close to the bare code and do a fair amount of typing (and even, dare I say it, some cut and paste) as I get the syntax locked into my brain. So right now I'm still mainly working in TextMate . Mileage varies, though, so if you're a hardcore IDE person it's nice to see how easy it is to set up a powerful free one for this stuff.

A Layer on Top of Rails

Interesting - What is Hobo? describes Hobo, which bills itself as "the Web App Builder for Rails." Basically, it's a set of plugins to add even more DRY and RAD features to the Rails framework. I think I need to spend some more time digging into plain vanilla Rails first (if there is such a thing), but this looks like it's a rather mature project and worth some exploration in the future.

A Couple of Mac Tools


  • SQLGrinder is another DBA tool, this one using JDBC for connectivity. $59 to register. My initial attempts at using it to connect to a MySQL database on a different machine weren't successful, but then, so far everything I've tried to connect to a MySQL database on a different machine have been unsuccessful.



  • BuildFactory is a continuous integration tool that runs on the Mac, integrated with Subversion and various editors. $35 to register. I don't need this yet, but might come in handy in the future.

Pointless but Cute

Yeah, so the world doesn't really need Twitterific , but then, there are many other mildly fun addictions it doesn't need either.

Making the Switch

James Higgs has been on the PC-to-Mac trail longer than I have. His Mac OS X applications I use post has plenty of links that I'll be checking out (though, thankfully, I think I'll be able to avoid putting MS Office on my Mac).

Tracking Traffic

I admit it, I watch traffic to my various Web sites. Terrible character failing, I know. Anyhow, at the moment A Fresh Cup is on track to get somewhat less traffic in a month than Larkware gets in a single day. So I guess I've got a ways to go. By the end of the year I'd like to see this site built up to the point where it's got the sort of authority that that one does, only in a new field. Of course, there are some barriers to that: right now, I don't know much, and not many people know that I'm over here. But I'm learning fast (I hope) and word is slowly spreading. Stay tuned, and feel free to tell your friends to come and visit.

Ruby Cheat Sheets

Another cool resource: cheat sheets features close to 100 command-line cheat sheets for Ruby and associated coding - the one on Capistrano helped me out immensely tonight, and I've got my eye on a couple of others (TextMate for Rails, for example). You can access them all online in HTML glory, or


$ gem install cheat

will bring it into your local system where you can access the cheat sheets directly from the command line.

Another Application

I've still been putting my personal 20% time to reasonably good use. Tonight I deployed LarkWrite - a new home for my personal journal, with software custom-written in Rails. I kept an online journal for five years or so and then got too busy and got out of the habit, but it's time to get back into it again. The application is just barely functional enough to use right now - it lets me enter and markup and display stuff, and has a few different display modes, and probably has some bugs as well. But I'm reasonably pleased at how it's coming along, and considering that it's still under 200 lines of code I'm happy with the implementation as well.

I'll be tweaking on this one and adding features for a bit. When I think it's in a more ready state I'll make the source available as well. Then it's on to the next application.

subscribe via RSS