justinfrench/formtastic — Issue #758: column.limit returning nil from pg adapter
Author: rubythings
Created: 2011-12-16 10:08:04+00:00
State: open

I've run into a problem trying to upgrade to 2.0.1 running with a postgres database using the pg 0.12.0 adapter (though earlier versions have the same problem). I've tracked this down to the inputs/base/validations.rb file where we have

def column_limit
if column? && column.respond_to?(:limit)
case column.type
when :integer
(2 ** (column.limit * 8)).to_s.length + 1
else
column.limit
end
end
end

column.limit is returning null for integer values, so this is breaking formtastic. I've pu a nasty hack in my copy to set a default (col = column.limit || 4). A better solution would be to address this inside the postgres adapter, but I'm reporting here in case others need a quick fix, or someone can come up with a better idea.