I did something similar recently and approached it as a three-step process. There may be more Rails ways to do this, but this method worked for me and was painless.
I used an iterative approach and took advantage of the fact that MongoDB is actually a very relational friendly document storage system. I started with a relational installation using the Mongoid Relational Associations (at the bottom of the page) syntax reference_many and referenced_in. Once everything worked, I reorganized iteratively to a more document-oriented approach.
1. Reset the existing database directly to MongoDB
I used my existing models to brute-force the SQL table and SQL data into parallel MongoDB documents. I just slammed everything that I had, without worrying about names or relationships; strict display of tables in the collection 1: 1.
It was a one-time process for me. Once everything is here, steps 2 and 3 take this data and transform it into the structure I wanted. I could also change my models since I no longer need to interact with the relational system. You might want to create some kind of copy of existing models if you need to return to this step for any reason.
2. Data transfer
In the next step, I went with the ruby ββcustom shell application. Again, this might be the best way to do this using Rails functions, but I went using the script's direct transaction method.
I used raw MongoDB Ruby driver , read the database created in step 1, and converted the source collections to the forms I wanted. I used a separate database for the recipient from the one that was created in step 1, because I iteratively modified this script to become more and more document-oriented, as I reorganized my model in step 3.
3. Referential models as needed
I reorganized my model for working with the database created in step 2, skipped my tests, and then returned to the script in step 2 and made changes to make the database more document-oriented.
I repeated steps 2 and 3 until I reworked the models and layouts of the documents until I reached the final result.