I have a model that has a field called category_paths. This is JSONBin postgres.
When I set category_pathsfrom factory_girl, factory_girl changes the value type to String. Consider the following code, although I assign it Hash, it gets the value String.
FactoryGirl.define do
factory :product do
title "MyString"
after(:build) do |p|
p.category_paths = Hash.new
puts p.category_paths.class
end
end
end
This is strange, and I can’t understand what is happening. This works great when trying from the Rails console. The problem only occurs when used in a factory. So does factory_girl work? Or is there a way to control this behavior?
Here is the product model
class Product < ActiveRecord::Base
acts_as_copy_target
searchkick autocomplete: ['brand'], callbacks: :async
scope :search_import, -> { includes(:product_offers) }
has_many :product_offers, autosave: true
validates :title, presence: true
validate :validate_category_paths
end
Any help would be appreciated
source
share