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

dirty_attributes not flagging correctly?

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

      When doing

      c = Category.new
      c.name = "Foobar"
      c.name_changed? # Returns true

      name_changed? returns true, as one would expect, but when you create a new Category by doing

      c = Category.new(:name => "Foobar")
      c.name_changed? # Returns false

      name_changed? returns false, is this how its supposed to work? As its not quite what I was expecting and feels much like a bug!

      My Model can be found below for reference.

      1. app/models/category.rb
        class Category
        include Mongoid::Document
        include Mongoid::Timestamps

      field :name, :type => String
      field :slug, :type => String

      attr_accessible :name

      validates :name,
      :presence => true
      end

            Assignee:
            Unassigned Unassigned
            Reporter:
            mikespokefire Michael Smith
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: