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

object.valid? converts array values to string

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.0.4
    • Affects Version/s: None
    • Component/s: None

      i have this model:

      class Entry
        include Mongoid::Document
        include Mongoid::Timestamps
      
        has_and_belongs_to_many :entries
      
        field :_id, :type => String
      
        field :user_ids, :type => Array, :default => []
        field :body, :type => String
        field :score, :type => Float
        field :service, :type => String
      ...
      end
      

      Then i do this:

      Unable to find source-code formatter for language: text. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      entry = Entry.new :entry_ids => [true, 1, "2"]
      => #<Entry _id: , _type: nil, created_at: nil, updated_at: nil, entry_ids: [true, 1, "2"], user_ids: [], body: nil, score: nil, service: "">
      entry.valid?
      => false
      entry
      => #<Entry _id: , _type: nil, created_at: nil, updated_at: nil, entry_ids: ["true", "1", "2"], user_ids: [], body: nil, score: nil, service: "">
      

      As you see all entry_ids values are converted to strings.

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

              Created:
              Updated:
              Resolved: