Why you should freeze Rails on a shared host environment


almost 11 years ago by Paul Sturgess on paulsturgess.co.uk articles.
When you upload your site you need to run the freeze gems rake command. Freeze is cool according to David Heinemeier Hansson and it will ensure your site...

How to build a simple ajax search in Ruby on Rails


almost 11 years ago by Paul Sturgess on paulsturgess.co.uk articles.
I've just implemented a simple ajax search on my site and i'm going to explain how I did it. In my view: <%= start_form_tag({}, {:id => "search...

Passing variables between views and layout templates with Ruby on Rails


almost 11 years ago by Paul Sturgess on paulsturgess.co.uk articles.
One of the most useful discoveries I have made with Rails is the ability to pass variables from a layout to a view and vice versa. This means I can set...

How to evaluate the size of a file upload in Ruby on Rails


almost 11 years ago by Paul Sturgess on paulsturgess.co.uk articles.
Sometimes it's useful to show how large a file is on a wesite. If anything, showing the file size allows the user to guage roughly how long it's going to...

How to add a css class to start_form_tag in Ruby on Rails


almost 11 years ago by Paul Sturgess on paulsturgess.co.uk articles.
To add a class to a form in Ruby on Rails using start_form_tag isn't immediately obvious. I achieved it like this: <%= start_form_tag( {}, {:class...

How to check if a file exists in Ruby on Rails


almost 11 years ago by Paul Sturgess on paulsturgess.co.uk articles.
Sometimes file uploads can go wrong; rather than risk your Rails app falling over, it makes sense to check if the file actually exists. Your database might...

How to output a boolean true or false to display yes or no in Ruby on Rails


almost 11 years ago by Paul Sturgess on paulsturgess.co.uk articles.
So you have a boolean check in your database and you want to convert the output from saying "true" or "false" to something more readable like "yes" or ...

How to truncate text in Ruby on Rails


almost 11 years ago by Paul Sturgess on paulsturgess.co.uk articles.
It's really simple to truncate text in Rails, just pass the function the text, the max number of characters you want to show and a truncate string you want...

Wrong number of arguments (2 for 1) Ruby on Rails error


almost 11 years ago by Paul Sturgess on paulsturgess.co.uk articles.
The best way for me to explain how I solved my Wrong number of arguments (2 for 1) error in Rails is by example. Basically I wanted to find all my departments...

Capistrano-Standing Room Only


almost 11 years ago by PragDave on PragDave.
It was standing-room only at Mike Clark's Capistrano talk: one of the first talks at this year's RailsConf. Latecomers stole chairs from other rooms...