Paul Sturgess

Pure CSS method to indicate the page you are on


almost 12 years ago by Paul Sturgess on paulsturgess.co.uk articles.
The idea of this method is to allow you to target a specific navigation item with css. You must place a unique id on the body of each page in your site...

Custom foreign keys in ruby on rails


almost 12 years ago by Paul Sturgess on paulsturgess.co.uk articles.
Custom foreign keys in Rails are handy if you have a legacy database where you cannot change table/field names. In my case it wasn't to do with a legacy...

Using del.icio.us to display links on your website


almost 12 years ago by Paul Sturgess on paulsturgess.co.uk articles.
Originally I had written a link manager into the admin for this site until I decided del.icio.us was the best way to manage my bookmarks. The reason for...

undefined method `body=' NoMethodError in Ruby on Rails


almost 12 years ago by Paul Sturgess on paulsturgess.co.uk articles.
Not a reserved word or magic fieldname this time. But apparantly "response" is something special in Rails, "request" is too. So when I attempted to use...

Alternate row classes with Ruby on Rails


almost 12 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...

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


almost 12 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...

Backing up your database with a cron job on Bluehost


almost 12 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...

Paginate the results of a query in Ruby on Rails


almost 12 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...

Creating an RSS feed in Ruby on Rails


almost 12 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...

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


almost 12 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 =>...