AaronLasseigne/active_interaction

Activeinteraction::Inputs and ActiveRecord #build_where_clause

VStetsyshyn opened this issue · 1 comments

Hey, thank you to the author of this gem and all contributors.

After upgrading rails from version 6.0.3.7 to 6.1.0+ I faced with ActiveRecord issue when I made it in my interaction class User.find_by(inputs)
ArgumentError: Unsupported argument type: { .... } (ActiveInteraction::Inputs) from gems/activerecord-6.1.0/lib/active_record/relation/query_methods.rb:1094:in `build_where_clause

Through debugging I see that in the new version of ActiveRecord lib changed the method https://github.com/rails/rails/blob/v7.0.3.1/activerecord/lib/active_record/relation/query_methods.rb#L1285
inside this method is "case when clause" which checks input types.

The type of inputs is inputs.is_a? Activeinteraction::Inputs => true so there is no such type as Activeinteraction::Inputs inside method build_where_clause.

The solutions can be as made all requests like User.find_by(**inputs) or User.find_by(inputs.to_h)
Maybe I'm missing something or there is a better way to fix my issue. The idea is to force inputs to Hash type.

Thank you, and will appreciate the answers.

The solutions can be as made all requests like User.find_by(**inputs) or User.find_by(inputs.to_h)
Maybe I'm missing something or there is a better way to fix my issue. The idea is to force inputs to Hash type.

This is the correct solution.