validates_uniqueness_of

Hello,

I have just switch to Edge Rails and using validates_uniqueness_of: I
have this error ( what is strange is that I don't have this error with
another Model that uses validates_uniqueness_of ....)

Model
  validates_uniqueness_of :user_id

Error
wrong number of arguments (1 for 2)
vendor/rails/activerecord/lib/active_record/validations.rb:698:in
`exists?'
vendor/rails/activerecord/lib/active_record/validations.rb:698:in
`validates_uniqueness_of'
vendor/rails/activerecord/lib/active_record/base.rb:1927:in
`with_scope'
vendor/rails/activerecord/lib/active_record/base.rb:1935:in
`with_exclusive_scope'
vendor/rails/activerecord/lib/active_record/validations.rb:697:in
`validates_uniqueness_of'
vendor/rails/activerecord/lib/active_record/validations.rb:400:in
`validates_each'
vendor/rails/activerecord/lib/active_record/validations.rb:397:in
`each'
vendor/rails/activerecord/lib/active_record/validations.rb:397:in
`validates_each'
vendor/rails/activesupport/lib/active_support/callbacks.rb:182:in
`call'
vendor/rails/activesupport/lib/active_support/callbacks.rb:182:in
`evaluate_method'
vendor/rails/activesupport/lib/active_support/callbacks.rb:166:in
`call'
vendor/rails/activesupport/lib/active_support/callbacks.rb:90:in `run'
vendor/rails/activesupport/lib/active_support/callbacks.rb:90:in
`each'
vendor/rails/activesupport/lib/active_support/callbacks.rb:90:in
`send'
vendor/rails/activesupport/lib/active_support/callbacks.rb:90:in `run'
vendor/rails/activesupport/lib/active_support/callbacks.rb:277:in
`run_callbacks'
vendor/rails/activerecord/lib/active_record/validations.rb:969:in
`valid_without_callbacks?'
vendor/rails/activerecord/lib/active_record/callbacks.rb:285:in
`valid?'
vendor/rails/activerecord/lib/active_record/validations.rb:948:in
`save_without_dirty'
vendor/rails/activerecord/lib/active_record/dirty.rb:79:in
`save_without_transactions'
vendor/rails/activerecord/lib/active_record/transactions.rb:128:in
`send'
vendor/rails/activerecord/lib/active_record/transactions.rb:128:in
`with_transaction_returning_status'
vendor/rails/activerecord/lib/active_record/connection_adapters/
abstract/database_statements.rb:66:in `transaction'
vendor/rails/activerecord/lib/active_record/transactions.rb:82:in
`transaction'
vendor/rails/activerecord/lib/active_record/transactions.rb:90:in
`transaction'
vendor/rails/activerecord/lib/active_record/transactions.rb:127:in
`with_transaction_returning_status'
vendor/rails/activerecord/lib/active_record/transactions.rb:98:in
`save_without_after_commit_callback'
vendor/rails/activerecord/lib/active_record/transactions.rb:110:in
`rollback_active_record_state!'
vendor/rails/activerecord/lib/active_record/transactions.rb:98:in
`save_without_after_commit_callback'
vendor/plugins/thinking-sphinx/lib/thinking_sphinx/active_record/
delta.rb:38:in `save'
app/controllers/evaluations_controller.rb:24:in `create'

Has anyone any ideas ? :slight_smile:

Thank you very much,

Pierre

Has anyone any ideas ? :slight_smile:

Thank you very much,

Have you overridden the method exists? on that model? The default
implementation takes one argument and your stacktrace implies that
it's expecting two. The uniqueness validation relies on this method
now, which is why you didn't see it earlier.

Thanks Michael, you were right !

Have a nice day, Pierre.