views:

29

answers:

1

We are using has_many_polymorphs along with acts_as_list. Everything works fine locally, but on heroku, we get an error everytime a couple of acts_as_list methods are called. Namely those that update a number of records with new positions because of an addition or a deletion of an item in the list.

Example of acts_as_list method:

def decrement_positions_on_higher_items(position)
        acts_as_list_class.update_all(
          "#{position_column} = (#{position_column} - 1)", "#{scope_condition} AND #{position_column} <= #{position}"
        )
      end

Example of Postgres error

ActiveRecord::StatementInvalid (PGError: ERROR:  operator does not exist: character varying - integer 
LINE 1: UPDATE "ads_placements" SET position = (position - 1) WHERE ...</p>
                                                         ^

AdsPlacment.rb

acts_as_list :scope => 'placement_id=#{placement_id} AND placement_type=#{quote_value placement_type}'
+1  A: 

Turns out it was a postgres column type error. (character varying - integer)

Jarrett