1

I have an ActiveAttr model and I want to do a lookup on certain data using ActiveRecord

class Api::V1::Salesubmit

  include ActiveAttr::Model
  include ActiveModel::Validations::Callbacks

  attribute :secret

  .
  .
  .

  validate :validate_merchant

  def validate_merchant

    # Lookup merchant here
    #
    Merchant.where('secret = ?', self.secret).first

  end

end

However even though I have a merchant defined it is not found. Also a

Merchant.all.size

returns 0 even though there is a merchant stored.

Is there a way to access data via ActiveRecord from within the validation from ActiveAttr?

Lasse Laursen
  • 131
  • 1
  • 8

0 Answers0