title: Using Mongo Update and $set to insert field (throwing error)
body: <p>Ok, this is probably a stupid question but I have been reading and trying different queries and for some reason I cannot get this to work without throwing an error. This is my first time working with MongoDB and it is in an RoR project. We set up charities to have a twitter handle field, but it was not put into the model originally. So we populated the DB with charities, but now none of them have the twitter handle field. I added it to the model so now all others created will have it.</p>
  
  <p>My issue is when I try to update the charities already in my DB I keep getting an error pointing at $set: </p>
  
  <pre><code>namespace :add_tw_handles_fields_2013_6_13 do
  
    desc "add_tw_handle"
    task :add_tw_handle =&gt; :environment do |t, args|
      # db.charity.update( { featured: false }, { $set: { tw_handle : "test"}}, false, true)
  
      # got your 6
     Charity.update({ },
        { 
          $set: { "tw_handle": "test"}
        },
        { multi: true }
      })
  
    end
  end
  </code></pre>
  
  <p>I tried the 2 synax calls above, I was reading in these 2 docs <a href="http://docs.mongodb.org/manual/reference/method/db.collection.update/" rel="nofollow">http://docs.mongodb.org/manual/reference/method/db.collection.update/</a>   <a href="http://docs.mongodb.org/manual/core/update/#Updating-The%24positionaloperator" rel="nofollow">http://docs.mongodb.org/manual/core/update/#Updating-The%24positionaloperator</a>.</p>
  
  <p>I always get this error tho:</p>
  
  <pre><code>add_tw_handles_fields_2013_6_13.rake:16: syntax error, unexpected ':', expecting tASSOC
          $set: { 
  </code></pre>
  
  <p>As far as I can tell that is the correct syntax. I am running this in the script so I don't think I need the db. before my Model name (as shown in the uncommented update) right? I am new to this, but I literally copied and pasted the example and filled out my info, and nothing. I then tried adding a query, but there is never an error until it gets to $set: and I have no idea why. It is exactly as is shown in the Mongo docs linked above.</p>
  
  <p>Any insight into what my issue would be greatly appreciated.</p>
  
  <p>Thanks,</p>
  
  <p>Alan    </p>