Interning empty string error in Ruby on Rails

I don’t like writing short posts about fixing code errors but I think this one deserves a quick shout out. If you get an error in your Rails application that says “interning empty string”, there could be something wrong with an error message in your validations. For example, I had something like:

def geocoding_works_when_geotarget_is_true
    if geotarget and (self.lat == nil or self.lng == nil or self.address_changed?)
      errors.add("Provide better location information so that we can geotarget your reminders.") unless geocode
    end
end

The ‘.’ in my error message caused an “interning empty string” error. I hope I save someone an hour by posting this.

No TweetBacks yet. (Be the first to Tweet this post)
Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • MySpace
  • Slashdot
  • StumbleUpon
  • Technorati
  • TwitThis

If you enjoyed this post, make sure you subscribe to my RSS feed!

This entry was posted in Software and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

5 Comments

  1. Posted January 1, 2010 at 8:53 am | Permalink

    Excellent post. saved me hours of digging into the problem. Did you find out why this problem occurs?

  2. Posted January 2, 2010 at 12:15 pm | Permalink

    Haven’t looked into it much further. Drop a comment if you find out.

  3. Sean McCleary
    Posted February 9, 2010 at 12:46 am | Permalink

    Thank you for this post. You saved me a ton of debugging time. That is a strange Rails bug.

  4. Posted February 12, 2010 at 10:35 am | Permalink

    Thank you so much for this. I murdered an hour on this before resorting to Google. Found your page right away, and in my case it was “…” in the error message causing the problem.

  5. Posted February 12, 2010 at 10:39 am | Permalink

    I’m glad this is saving people time. It’s sort of a lame post but serves the intended purpose.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">