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

Case sensitive validation problem

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

      I updated mongoid to 3.0.0 from 2.4.9 and have a problem with validation, there's:

      1.9.3p125 :040 > p = Elite::Post.create(

      {title: "sample title", short: "short message"}

      )
      => #<Elite::Post _id: 4ffe6d189e3e72c50d00000c, _type: nil, created_at: 2012-07-12 06:22:16 UTC, updated_at: 2012-07-12 06:22:16 UTC, title: "sample title", short: "short message">
      1.9.3p125 :041 > p = Elite::Post.new(

      {title: "Sample Title", short: "short message"}

      )
      => #<Elite::Post _id: 4ffe6d209e3e72c50d00000d, _type: nil, title: "Sample Title", short: "short message">
      1.9.3p125 :042 > p.valid?
      => true #must be false
      1.9.3p125 :043 > p.save
      => true
      1.9.3p125 :044 > Elite::Post.all.map(&:title)
      => ["sample title", "Sample Title"] # The posts a dublicated
      1.9.3p125 :064 > p = Elite::Post.new(

      {title: "Sample Title", short: "short message"}

      )
      => #<Elite::Post _id: 4ffe6eab9e3e72c50d00000e, _type: nil, title: "Sample Title", short: "short message">
      1.9.3p125 :065 > p.valid?
      => false
      1.9.3p125 :066 > p.save
      => false

      In the model I have:

      validates :title,
      presence: true,
      uniqueness: true

      or

      validates_uniqueness_of :title

            Assignee:
            durran Durran Jordan
            Reporter:
            korzhyk korzhyk
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: