ransack
ransack copied to clipboard
Ransack with serialized attributes not working on Rails 6
- performing a ransack for serialized attributes on Rails 6 throws
ActiveRecord::SerializationTypeMismatcherror
Conference class model
class Conference < ActiveRecord::Base
serialize :booked_location_uuids, Array
end
booked_location_uuidsis a text type column in theconferencestable
Example 1:
When trying to do a ransack on collection of Conference for the serialized attribute booked_location_uuids
collection = Conference.all
search_params = {'booked_location_uuids_cont' => 'L02'}
collection.ransack(search_params).result
An error is thrown, and this occurs after upgrading to Rails 6:
can't dump `booked_location_uuids`: was supposed to be a Array, but was a String. -- "%L02%"`
Example 2: using an array in the search params like this
collection = Conference.all
search_params = {'booked_location_uuids_cont' => ['L02']}
collection.ransack(search_params).result
throws the same error
ActiveRecord::SerializationTypeMismatch (can't dump `booked_location_uuids`: was supposed to be a Array, but was a String. -- "%[\"L02\"]%")
Ruby Version: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin17] Rails Version: Rails 6.1.6 Ransack Version: ransack-3.2.1
@prasanthkrajan what is the underlying database and can you please provide a copy of the schema.rb for the relevent table?
Or ... do a pull request with a failing test.