madeintandem / hstore_accessor

Adds typed hstore-backed field support to ActiveRecord models.
MIT License
242 stars 47 forks source link

Doesn't work with active record's uniqueness validation #47

Closed zzeon closed 9 years ago

zzeon commented 9 years ago
class StripePaymentPlan < PaymentPlan
  hstore_accessor :metadata,
    stripe_id: { data_type: :string, store_key: 'sid' }
  validates_uniqueness_of :stripe_id
end

Trying to call save, I get something like:

NoMethodError: undefined method `limit' for nil:NilClass
activerecord-4.1.8/lib/active_record/validations/uniqueness.rb:65:in `build_relation'

It seems ActiveRecord actually attempts to look up the column rather than checking the hstore column, any good ways to handle this?

zzeon commented 9 years ago

This is more of a issue with the uniqueness validator in Rails than hstore_accessor, so I am closing this.