Hi! I am quite new to Ruby on Rails and I am loving it so far. I have to work on a project with MongoDB and I noticed a few tutorials tell us to generate a new app without the ActiveRecord. I wonder if it's the best solution Why isn't a good idea to use ActiveRecord with Mongo? Maybe in the future, if we need to change the database, wouldn't it just the case of changing the database settings if we use ActiveRecord? I think there would be some gems that would make the bridge between ActiveRecord <-> MongoDB transparent as they do with MySQL or Postgres. Innocent me? Also, because it's schemeless, I am a bit lost when it comes to the workflow. Migrations are no longer necessary, right? So what would be the best workflow? We are probably going to use MongoID, but maybe MongoMapper. So, let's say Should I create a model, configure the model accordingly to MongoID and then controller? Or scaffold / scaffold_controller (never used this one)? (To be honest I never knew what was better if scaffold or model and controller.) Hope I am not asking too much! Thanks. Thiago.
on 2012-10-10 22:38
on 2012-10-10 22:49
On Wednesday, October 10, 2012 5:03:25 PM UTC+1, Thiago Rossi wrote: > they do with MySQL or Postgres. Innocent me? > > ActiveRecord is tied to the relational world at a a very deep level - it just can't talk to mongo and is unlikely ever to. Some other ORMs (such as data mapper) can handle both sql and nosql databases. Even with an ORM than handles both, my personal experience is that you can end up imposing your old relational habits on your non relational database which is non optimal. > Also, because it's schemeless, I am a bit lost when it comes to the > workflow. Migrations are no longer necessary, right? So what would be the > best workflow? > > You no longer have schema update migrations (eg adding columns). You will occasionally need to add indexes and you will still need data migrations if you change how store for your data (for example if you switch data from individual objects to embedded objects) > We are probably going to use MongoID, but maybe MongoMapper. So, let's > say Should I create a model, configure the model accordingly to MongoID > and then controller? Or scaffold / scaffold_controller (never used this > one)? (To be honest I never knew what was better if scaffold or model and > controller.) > > The controller / forms should be pretty much the same - that's the point of the ActiveModel interface that Active Record, MongoMapper, Mongoid conform to. Fred
on 2012-10-16 16:53
I think I didn't realise ActiveRecord and ActiveModel were different things. Thank you! Migration was a good way to solve that problem with schemes being update, but when it becomes famous we stop using it. LOL