How to specify the number of decimal places displayed in Ruby on Rails


over 10 years ago by Paul Sturgess on paulsturgess.co.uk articles.
The sprintf Ruby class provides the ability to specify the number of decimal places to display. sprintf("%.1f",track.ratings.average('rating')) In this...

How to pass an instance variable to a rendered partial in Ruby on Rails


over 10 years ago by Paul Sturgess on paulsturgess.co.uk articles.
Passing a variable to a partial means you can be clever about re-using your code to output different collections of data in the same way. Essentially you...

Getting Ruby on Rails running on Bluehost


over 10 years ago by Paul Sturgess on paulsturgess.co.uk articles.
Getting my site working on Bluehost wasn't entirely straight forward but now it's running there shouldn't be any more difficulties. If you're attempting...

Spring CSS Reboot - Out of the dark and into the light


over 10 years ago by Paul Sturgess on paulsturgess.co.uk articles.
Hopefully you should be seeing my new look and feel as part of the Spring CSS Reboot. The dark colour scheme of old has not gone forever; I have plans...

Tagging with Ruby on Rails


over 10 years ago by Paul Sturgess on paulsturgess.co.uk articles.
Large credit goes out to The Rails Diary for helping me get the tags going on this site. I wanted a many to many relationship between the aritcles and...

Printing the alphabet easily in Ruby on Rails


over 10 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


over 10 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


over 10 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


over 10 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


over 10 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 =>...