oddcamp / active_hash_relation

ActiveHash Relation: Simple gem that allows you to run multiple ActiveRecord::Relation using hash. Perfect for APIs.
https://www.kollegorna.se/
MIT License
118 stars 15 forks source link

Rails 5 boolean type_cast_from_database to cast #21

Closed KRaymundus closed 7 years ago

KRaymundus commented 7 years ago

According to my error message and what I read here: In Rails 5, the boolean casting is to be done as: ActiveRecord::ConnectionAdapters::Column.cast(param) instead of: ActiveRecord::ConnectionAdapters::Column.type_cast_from_database(param)

So the filter_boolean function in column_filters.rb should become:

def filter_boolean(resource, column, param)
  b_param = ActiveRecord::Type::Boolean.new.cast(param)

  resource = resource.where(column => b_param)
end
vasilakisfil commented 7 years ago

@KRaymundus you are correct. I am adding tests on branch feat/tests and I will incorporate this by checking AR version. I will probably finish with adding tests end of this week and close this issue :)

vasilakisfil commented 7 years ago

Fixed on master, closing.