Validates_uniqueness_of fails on STI in Rails 2.3.2

I’ve got something like this:

class Position < ActiveRecord::Base
end

class CartItem < Position
validates_uniqueness_of :product_id
end

When I try to save CartItem I get this error:

ArgumentError: wrong number of arguments (1 for 2)
from
/home/joaz/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/validations.rb:758:in
exists?' from /home/joaz/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/validations.rb:758:invalidates_uniqueness_of’
from
/home/joaz/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2148:in
with_scope' from /home/joaz/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2156:inwith_exclusive_scope’
from
/home/joaz/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/validations.rb:757:in
validates_uniqueness_of' from /home/joaz/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/validations.rb:399:invalidates_each’
from
/home/joaz/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/validations.rb:396:in
each' from /home/joaz/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/validations.rb:396:invalidates_each’
from
/home/joaz/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/callbacks.rb:182:in
call' from /home/joaz/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/callbacks.rb:182:inevaluate_method’
from
/home/joaz/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/callbacks.rb:166:in
call' from /home/joaz/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/callbacks.rb:90:inrun’
from
/home/joaz/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/callbacks.rb:90:in
each' from /home/joaz/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/callbacks.rb:90:insend’
from
/home/joaz/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/callbacks.rb:90:in
run' from /home/joaz/.gem/ruby/1.8/gems/activesupport-2.3.2/lib/active_support/callbacks.rb:276:inrun_callbacks’
from
/home/joaz/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/validations.rb:1029:in
valid_without_callbacks?' from /home/joaz/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/callbacks.rb:315:invalid?’
from
/home/joaz/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/validations.rb:1008:in
save_without_dirty' from /home/joaz/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/dirty.rb:79:insave_without_transactions’
from
/home/joaz/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/transactions.rb:229:in
send' from /home/joaz/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/transactions.rb:229:inwith_transaction_returning_status’
from
/home/joaz/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in
transaction' from /home/joaz/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/transactions.rb:182:intransaction’
from
/home/joaz/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/transactions.rb:228:in
with_transaction_returning_status' from /home/joaz/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/transactions.rb:196:insave’
from
/home/joaz/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/transactions.rb:208:in
rollback_active_record_state!' from /home/joaz/.gem/ruby/1.8/gems/activerecord-2.3.2/lib/active_record/transactions.rb:196:insave’

Putting validates_uniqueness_of in the Position model works fine. It
doesn’t work in any inherited class. This seems to be a regression issue
on Rails 2.3, works fine on previous rails versions.

What other plugins are you using? Something weird is going on, as the
code at pointed to by the exception trace calls exists? with one
argument, which is what it expects.

–Matt J.

On Jun 17, 6:42 am, Joachim G. [email protected]

Matt J. wrote:

What other plugins are you using? Something weird is going on, as the
code at pointed to by the exception trace calls exists? with one
argument, which is what it expects.

gems included in config:
mislav-will_paginate
memcache-client

vendor/plugins (error occours also after renaming the vendor directory)

acts_as_acl
acts_as_tree
better_nested_set
view_model

In fact, I get the same error on a fresh rails installation.