You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've just started playing around with using Hashie to help build Rails form objects. I'd like to initialize a Hashie object with a HashWithIndifferentAccess (e.g., params), but also do some coercion/translation on the hash values. Something like this:
class VideoSearch < Hashie::Trash
include Hashie::Extensions::Dash::IndifferentAccess
property :per_page, default: 25, transform_with: lambda { |v| v.to_i }
end
However, the transform_with fails when I include the IndifferentAccess module; that is, the value is not converted to_i. If I comment out the include, then everything works as expected.
Any thoughts or solutions (other than calling symbolize_keys on my params hash before initialization)?
EDIT: I'm using Hashie 3.0.0.
The text was updated successfully, but these errors were encountered:
I've just started playing around with using Hashie to help build Rails form objects. I'd like to initialize a Hashie object with a
HashWithIndifferentAccess
(e.g.,params
), but also do some coercion/translation on the hash values. Something like this:However, the
transform_with
fails when I include theIndifferentAccess
module; that is, the value is not convertedto_i
. If I comment out theinclude
, then everything works as expected.Any thoughts or solutions (other than calling
symbolize_keys
on myparams
hash before initialization)?EDIT: I'm using Hashie
3.0.0
.The text was updated successfully, but these errors were encountered: