rails-settings-ui icon indicating copy to clipboard operation
rails-settings-ui copied to clipboard

why change array value to sym

Open StephenLiuYa opened this issue 7 years ago • 0 comments

     class Array
        def self.[](value)
          # array presented in checkboxes
          case value.class.name
          when 'Hash', 'ActiveSupport::HashWithIndifferentAccess'
            value.keys.map!(&:to_sym)
          when 'ActionController::Parameters'
            value.select{ |_,v| v == 'on' }.keys.map!(&:to_sym)
          else
            # or in select tag
            value.to_sym
          end
        end
      end

StephenLiuYa avatar Jun 13 '18 06:06 StephenLiuYa