Author Archives: Ashiq Alibhai

About Ashiq Alibhai

Ashiq Alibhai, PMP, has been a Rails aficionado since 2007, and developed web applications since early 2003, where he learned PHP in one summer. As the driving-force behind RailsRocket and the Launchpad project, he seeks to share the ease of development with Rails far and wide.

Regular Expressions in Ruby (and Rails)

How does Rails, or rather, Ruby, deal with Regular Expressions? There are a few things; first, the syntax for regular expressions is a bit unique in Ruby. Second, the String class has a few methods that you can use for regular-expression use–namely match and gsub, which you can use to match (groups) and access matches. Continue reading

Posted in Development | Tagged , | 19 Comments

Conditional Code

You’re writing some code for a new client. Debug statements litter the code. Oops, you sent that to the client. Oops, you’re printing out credit-card numbers. Identity theft ensues. Don’t move to Mexico–you can actually handle this problem in an elegant way by using conditional code statements INSIDE your class … Continue reading

Posted in Development | Tagged , , | Comments Off

Bort: Better Skeleton Applications

bort is a replacement for your standard Rails application skeleton. It comes with Restful Authentication, Will Paginate, code for using a MySQL database, database sessions, and more! Use it instead (it won’t hurt you), and it’ll help you bootstrap your Rails applications even faster (and in a better way)! Continue reading

Posted in Gems and Plugins | 2 Comments

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

String Replacement in Ruby

How can you replace strings in Ruby? There are a couple of options; there’s the tr function, which takes two sets of characters, and substitutes them; and there’s the gsub method, which makes a global replacement based on a regular expression. Powerful stuff! Continue reading

Posted in Development | Tagged , , | Comments Off

Ruby Command-Line Arguments

How can you access command-line arguments in Ruby? Through the special array called ARGV. It’s a zero-indexed array of your command-line arguments; so ARGV[0] is the first, ARGV[1] is the second, and so on. You can use ARGV.length to get the number of arguments, too. Continue reading

Posted in Development | Tagged , , | 1 Comment

Launchpad

Launchpad is an open-source article-based CMS and blogging platform for Rails. It has all the features you come to expect from a CMS, like admin-only edit links, commenting, voting, RSS feeds, future-publishing posts, and user registration. Best of all, it’s written 100% in Rails! Continue reading

Posted in Projects | Comments Off

Rails 2.1: Increment and Decrement Value

Prior to Rails 2.1, the increment and decrement functions needed to be called multiple times if you wanted to increment/decrement by more than one. In Rails 2.1, you can pass in a second parameter: a value, how much to increment or decrement the field by. (And it can take negative values.) Continue reading

Posted in Development | Tagged , | Comments Off

Chaining Array Appends With <<

In Ruby, you can push an element to an array using the << method. This method returns the array, so you can chain appends using it, like so: a << "One" << "Two". Nice! Continue reading

Posted in Development | Tagged , , | Comments Off

Rails 2.1: Aggregate Expressions

Rails 2.1 allows you to perform complex aggregate queries, such as Donation.sum(“amount * 3″). This makes complex calculations a snap! Rails provides functions for calculating the average, count, maximum, minimum, and the sum. Continue reading

Posted in Development | Tagged , , | Comments Off