problems and unexpected behaviour

Nothing's perfect, as we develop web applications we come across the odd thing that either doesn't seem to work quite right or works differently to the way we expected. These are our notes which we're sharing just incase someone else finds them helpful. We're not perfect too so if you think we've got something wrong then feel free to comment.

Ruby on Rails not rendering HTML in browser

I've just noticed someone has come to our blog after searching for the terms in the title of this page. It reminded me of a frustrating hour or so when I first started using rails where the RHTML page I was writing was doing (or not doing) just that. Just in case anyone is having the same newbie problem I'll hold my hand up say it was this:

make sure any embeded Rails code is surrounded by these delimeters:


 <%=      %> #(note the equals)

and not these:


<% %>

Hope this helps.

using Lightview, Prototype and jQuery on the same page

We're developing an e-commerce website albert & I. They're really nice people so I'll just give them a quick plug here, they're selling a new range of fashionable t-shirts designed in Paris and made in India using Fairtrade employers.

Microsoft Office 2007 and docx

Office 2007 introduced a new xml file format for their documents, docx, which seems to have caused some confusion amongst some of our clients. The Docx file format is specific to Office 2007 and doesn't work with other office applications or previous versions of Word. There are a number of ways that docx files can be converted to formats that others understand.

Microsoft Office, Excel and Word, rescue corrupted files

Just dispensed some advice to a client in trouble. It's a little trick that's helped me out a few times before so I thought I'd post it here in the hope others may find it useful.

Ruby on Rails, odd behaviour with common terms

I added a 'display' property to my job model to determine if that job should be displayed in some graphs on the web application I was building. When I came to accessing that value using check_box('job', 'display') the checkbox remained blank no matter what value was in the underlying model. Odder still, if I selected the checkbox and submitted then the correct selected value would go through so I was getting an end-to-end from view to database it's just that the checkbox control was behaving oddly.

Ruby on Rails, rake migrate add_column fails with The error occurred while evaluating nil.[]

This one had me stumped for a while:

I was attempting to add some columns using rake migrations but kept getting this error:


rake aborted!
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]

when running the migration below. Unfortunately it was the first time I'd used add_column so my immediate assumption was that I'd done something wrong.


class AddVatAndDisplayColumns < ActiveRecord::Migration
def self.up   

Ruby on Rails - empty string to_i

Just spent an hour wondering why tests were failing, partly my stupidity and partly the way Ruby handles .to_i on empty strings. I'd assumed that calling .to_i on an empty string would generate an error:

x = ""
x.to_i

However "".to_i resolves as zero

Ruby on Rails - Rake db:migrate - schema info doesn't exist

Was installing a Rails application on a clients machine and received this error on the first migration:


Mysql::Error: #42S02Table 'forms_production.schema_info' doesn't exist: SELECT version FROM schema_info

Ruby on Rails not rendering HTML in browser

I've just spent an hour tracking down this odd behaviour. The HTML returned when a _form partial created by rails scaffold for 'company' objects was not rendering in the browser when served from our live server i.e. when users tried to edit or create a new company the browser was displaying the HTML as text. In test (on my laptop) the form was displaying as expected.

After a bit of tinkering - basically removing section of the form code until it worked - I realised that some tired developer, I suspect myself, had put in a checkbox for a method that didn't exist:

Syndicate content