Paul Sturgess

Using contants in environment.rb in Ruby on Rails


almost 11 years ago by Paul Sturgess on paulsturgess.co.uk articles.
Constants help with consistency, they easily allow you to keep your code DRY. One of the ways I utitilise constants is to standardise the date formatting...

Using helper methods in Ruby on Rails


over 10 years ago by Paul Sturgess on paulsturgess.co.uk articles.
This is a quick and simple intro to using helper methods in Ruby on Rails. I'll demonstrate some simple and tidy techniques for using html, strings andWha...

Counter_cache in ruby on rails 1.2.2


over 10 years ago by Paul Sturgess on paulsturgess.co.uk articles.
I came across a rather odd Rails gotcha today whilst trying to use the counter_cache method. Counter cache is a magic field that you can use with belongs_to...

Using constants in environment.rb in Ruby on Rails


over 10 years ago by Paul Sturgess on paulsturgess.co.uk articles.
Constants help with consistency, they easily allow you to keep your code DRY. One of the ways I utitilise constants is to standardise the date formatting...

Using ruby methods map and zip along with Rails extended finds


over 10 years ago by Paul Sturgess on paulsturgess.co.uk articles.
This is a combination of techniques that I find useful when you need to output related data from various database tables in the same list. In this example...

Calling dynamic methods in Ruby on Rails


over 10 years ago by Paul Sturgess on paulsturgess.co.uk articles.
To utilise dynamic method names in Ruby on Rails you can use Ruby's send method to pass a message to an object. For example: ["foo", "bar"].each do |method...

Site update


over 10 years ago by Paul Sturgess on paulsturgess.co.uk articles.
I try to avoid posting anything other than Ruby on Rails related posts but I thought I'd better mention the changes I've just uploaded to this site. Essentially...

How to destroy an array of objects with one line of code in Ruby on Rails


over 10 years ago by Paul Sturgess on paulsturgess.co.uk articles.
The easiest way is to collect all the id's of the objects you want to delete and then use the destroy method on the model of those objects. Model.destroy...

Wrong number of arguments (0 for 1) on notifiy method in Ruby on Rails


over 10 years ago by Paul Sturgess on paulsturgess.co.uk articles.
So I just got a cryptic error message: "Wrong number of arguments (0 for 1)" when using the check_box helper thus: f.check_box :notify Clearly I am providing...

Using helper methods in Ruby on Rails


~10 years ago by Paul Sturgess on paulsturgess.co.uk articles.
This is a quick and simple intro to using helper methods in Ruby on Rails. I'll demonstrate some simple and tidy techniques for using html, strings andWha...