views:

36

answers:

1

I have an ActiveRecord before_save method throwing an odd error:

class MyThing < ActiveRecord::Base
  before_save :dostuff

  def dostuff
    p self.class.maximum(:mycolumn)
  end
end

When I was using SQLite this worked perfectly, now—with postgresql—I get the error:

PGError: ERROR: current transaction is aborted, commands ignored until end of transaction block : SHOW max_identifier_length

The .maximum method works outside that dostuff method, so I guess I'm just asking too much at once? Is there another way to get the maximum value of an integer column that will work inside a before_save?

+1  A: 

The errormessage is about the max_identifier_length, the maximum length of an objectname (table, column, etc.). It has nothing to do with the SQL-function MAX(). Looks like you're using an invalid name, a name greater than 63 characters.

Frank Heikens