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

update_attributes fix

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

      Hi,

      I've started working with your awesome Mongoid on Rails3beta3 and Ruby 1.9.2-head. Today I built up my db, create and delete records, the problems comes when I've to update a record like this:

      p = Person.first
      p.update_attributes(:name => "John")
      (it returns true)

      When I recall Person.first the object wasn't updated and nothing happened in the log.
      So I try to dig into your code to find out a solution.
      To solve this problem I modified a method in Attributes module, I paste it here:

      def process(attrs = nil)
      (attrs || {}).each_pair do |key, value|
      if set_allowed?(key)
      modify(key.to_s, @attributes[key.to_s], value)
      @attributes[key.to_s] = value
      elsif write_allowed?(key)
      modify(key.to_s, @attributes[key.to_s], send("#

      {key}

      =", value))
      end
      end
      setup_modifications
      end

      Let me know if I made some mistakes or if you like it.
      Bye
      Giacomo

            Assignee:
            Unassigned Unassigned
            Reporter:
            giacomomacri Giacomo Macrì
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: