Printing the alphabet easily in Ruby on Rails


~11 years ago by Paul Sturgess on paulsturgess.co.uk articles.
It's really easy to print out the alphabet with Ruby. I needed to do recently as an additional method for searching by letter. Although, I could see it...

A footer that stays at the bottom of the browser window


~11 years ago by Paul Sturgess on paulsturgess.co.uk articles.
The footer on this site will always be at the bottom of the browser window, unless the content is longer than the window height. In which case it will just...

Using routes.rb to help you structure your Ruby on Rails app


~11 years ago by Paul Sturgess on paulsturgess.co.uk articles.
Routes.rb is a really powerful and one the most impressive features of the Rails framework once you work out how to use it. Flat pages Rather than using...

How to format dates in Ruby on Rails


~11 years ago by Paul Sturgess on paulsturgess.co.uk articles.
To format dates in Ruby you can use the strftime directive that makes up part of the Ruby base library. For example I used... to output March 2006...

How to assign a css class or id to link_to method in Ruby on Rails


~11 years ago by Paul Sturgess on paulsturgess.co.uk articles.
To assign a css class or id to a link_to method you do the following: <%= link_to "Link name", { :controller => 'controller_name', :action =>...

Creating an RSS feed in Ruby on Rails


~11 years ago by Paul Sturgess on paulsturgess.co.uk articles.
Creating an RSS feed for your website in Ruby on Rails is very simple. To set it up on this site I added the following lines to my articles controllerdef...

Paginate the results of a query in Ruby on Rails


~11 years ago by Paul Sturgess on paulsturgess.co.uk articles.
To paginate the results of a query you need to use conditions. Which can easily be combined into the default pagination built into Rails. So you can do...

Backing up your database with a cron job on Bluehost


~11 years ago by Paul Sturgess on paulsturgess.co.uk articles.
Bluehost provide a cron job set up interface in the control panel that makes it easy to set up cron jobs. The command I use is: mysqldump -u DBUSERNAME...

wrong argument type String (expected Module) Ruby on Rails error


~11 years ago by Paul Sturgess on paulsturgess.co.uk articles.
I got the error wrong argument type String (expected Module) because I was trying to create a select drop down for a field called 'Type'. However, 'Type...

Alternate row classes with Ruby on Rails


~11 years ago by Paul Sturgess on paulsturgess.co.uk articles.
Using the built in TextHelper cycle method makes alternate row classes so easy in Ruby on Rails. If your table rows are being ouput via a loop then you...