-
Type:
Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
It appears when I try to use simple_form's check_box collection generator.
The problem appears when action_view tries to check type of instance of Mongoid::Relations::Targets::Enumerable.
It can be issue of action_view, if it uses #is_a? method to check types, I think problem will disappear.
Here are direct links:
- https://github.com/mongoid/mongoid/blob/master/lib/mongoid/relations/targets/enumerable.rb
- https://github.com/rails/rails/blob/3-2-13/actionpack/lib/action_view/helpers/form_helper.rb#L1163
Here is code identical to mongoid's Mongoid::Relations::Targets::Enumerable and how action_view checks type with case/when
require "active_support/core_ext/module/delegation" class T include Enumerable delegate :===, :is_a?, :kind_of?, to: [] end t = T.new p t.is_a?(Array) # returns true p t.kind_of?(Array) # returns true p t.===(Array) # returns false p Array.===(t) # returns false # returns "unknown" case t when Array p "ary" else p "unknown" end