So, I have an application using rails 3 and mongodb that serve files. I want to import all files into gridfs using the runner process without creating a new ObjectId for files already on the system. Essentially, I want to bind files using a carrier to a file object already in the database.
For some reason, when I create a new file, I can mount the local file without any problems. However, I cannot attach a local file to a previously created document.
I tried all forms of updating Mongoid, and every time I get a method, a missing or unrecognized method.
So, for example, this works:
somefile = Upload.new( :name => "somefile.ext" ) somefile.upload = File.open("/foo/bar.ext") somefile.save!
But this is not so:
somefile = Upload.first(:conditions => {:name => "somefile.ext"}) somefile.upload = File.open("/foo/bar.ext") somefile.save!
Any ideas?
source share