Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-3044

Problem with checking types in action_view/form_helper

    • Type: Icon: Task Task
    • Resolution: Done
    • 4.0.0 final
    • 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:

      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
      
      

            Assignee:
            durran Durran Jordan
            Reporter:
            Zhomart Zhomart [X]
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: