Tag Archives: launchpad

CSS Progress Bar

How can you create a progress-bar with pure CSS, no images? In this post, we discuss one such attempt by Launchpad–where we have a target article-count goal, which we display in the dashboard. And we use a progress bar that’s pure CSS. Continue reading

Posted in Development | Tagged , | 1 Comment

Rails 2.1: Named Scope

Rails 2.1 introduces something called named scopes; named scopes allow you to create named collections on a class-level for your models, such as Article.published. You can chain named scopes together, and even create parameterizable scopes by using the lambda keyword; you can pass in variables, of a sort, and Rails will plug the values into your named scope queries. Continue reading

Posted in Development | Tagged , , | 4 Comments

Functions as First-Class Objects

A lot of programming languages have functions as first-class objects (you can pass them around, execute them, etc.) Ruby has some sort of functionality like that (proc and functors and yield, oh my!), but there’s a simpler solution: the (albeit abusable) eval method. Continue reading

Posted in Development | Tagged , , | 4 Comments

Drilling Down into Validation Failure

Rails provides model-level validation, which is easy and DRY. But if you have a class that validates multiple fields, how can you verify if validation is failing on the right fields? ActiveRecord provides a convenient errors method with an invalid? method you can call; it takes a field name. Continue reading

Posted in Testing | Tagged , , | 1 Comment

Page Rendering Time

A lot of websites show the page rendering time at the bottom. How can we implement this in our Rails website? We discuss a simple approach, where you wrap between two calls to Time.now (to get the current time). Subtracting them yields the time difference, in fractional seconds. Continue reading

Posted in Development | Tagged , , | 1 Comment

Generating a Google Sitemap

How can you generate a Google Sitemap for your website? There’s no widely-used pre-existing solution; you can roll your own sitemap fairly easily (using the XML builder in Rails), and plug in all the necessary model data to get a sitemap custom tailored to your needs. We provide a tested, validated sitemap template for you to modify. Continue reading

Posted in Development | Tagged , , , , | Comments Off