Ruby on Rails to_sym ArgumentError: interning empty string on startup

Posted on 21 February 2011

Recently when I deployed a Rails application onto the staging server I got a Passenger error page telling me the application wouldn't start. The full error was:

/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_view/template.rb:226:in `to_sym':ArgumentError: interning empty string

Essentially it's saying you can't call to_sym on an empty string. Unfortunately no great clues as to why this might be happening.

Looking at the backtrace revealed the source of issue was triggered by the valid_locale? method in Action View.

Such is the beauty of Rails I've never really had the need to delve into this method before to see what's going on. However, after a bit of digging I could see that Rails checks all the extensions of the view files to determine the language. Clever.

So I stuck in a simple rescue around the method call and output the full path of the file it was running this method on. This revealed the problem, a file had been checked into the repository, unknown to me, that had a filename in the format:

foo..html.erb

I removed the extra period and everything worked. I hope this saves someone out there the time I wasted hunting this down!

About Paul

Paul works for Kyan web design agency in Surrey, UK as a Ruby on Rails developer.

Follow Paul on Twitter

Email: paulsturgess [at] gmail.com

Read more articles in the archive →

Got something to say?