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

Dynamic attribute readers/writers fail to define when attribute name has special chars

      I create dynamic attributes and some of them have spaces or other unicode characters not compatible with ruby identifier syntax for naming methods. For example, i have a dynamic attribute named 'phone number 2'. Using define_method, there is no problem defining any type of method which uses this name. However, in Mongoid, it uses class_eval which causes my application to crash:

      def define_dynamic_before_type_cast_reader(name)
        class_eval <<-READER
         def #{name}_before_type_cast
           attribute_will_change!(#{name.inspect})
          read_attribute_before_type_cast(#{name.inspect})
        end
        READER
      end

      Now I cannot use form builder elements like f.text_field 

      Is there any temporary solution around this bug?

       

       

       

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            danvig2 John Merlino
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: