rails:freeze:gems | freezzo.com

December 27, 2007

Rails error: syntax error, unexpected tINTEGER Object::1

Filed under: Ruby on Rails — Tags: , , , , — Randy @ 11:28 am

When trying to do a model.find(), I ran into the error, ’syntax error, unexpected tINTEGER Object::1′. If you have a table that uses a magic or reserved name, such as type, you will get this error. This error was a pain in the ass, but I figured out that you can get by it:

class SomeModel < ActiveRecord::Base
    self.inheritance_column = ''
end

The inheritance_column override is the key, basically giving it a different value to use. Hope this helps!

November 28, 2007

You have a nil object when you didn’t expect it!

Filed under: Ruby on Rails — Tags: , , , , — Randy @ 6:44 am

I found this cool little snippet of code somewhere on the internet. Anywhere you access an object in a view, adding the following will ensure the page doesn’t blow up:

 <%= @object.association.variable rescue nil %>

Of course, you won’t know if you have an error now either.

Powered by WordPress