I've just begun creating a rails application using mongomapper for my models. I'm wondering what solution should I use for bootstrapping my app with it.
All my previous experience is with ActiveRecord & PostgreSQL, in which I have used several gems for bootstrapping. The one I liked the most was bootstrapper (+ factorygirl + faker).
Does anyone know whether these work ok with mongomapper? Can anyone suggest better alternatives? Is there anything obvious I need to know when bootstrapping mongodb?
Factory_girl and faker works fine with MongoMapper.
So you can bootstrap your Rails app in the same way that before. Made some data in your db/seed.rb
Related
I heard about gems like faker or populator but they are a little bit old (populator does not seem to play well with Rails 3).
So my question is, what do you use to generate fixtures ?
If you are interested in new fixture framework for ruby, take a look on Fabrication. It's looks like FactoryGirl Rails but have more interested features. We are using it with Faker and it's fine. I think it's the best solution nowadays :)
Most people use FactoryGirl Rails, which works nicely with Faker for doing things like random names, to make test data during their tests.
If sometimes you just want to populate your Dev DB with some fake data to make your application work, you can still use FactoryGirl Rails and make a Rake task that will populate some data you need.
When migrating an existing web application built using Sinatra and Datamapper, how would one go about migrating it to a Ruby on Rails (v3.1) and ActiveRecord application?
For example, start by migrating to ActiveRecord first while still using Sinatra. Once completed, move to controllers, etc. Or perhaps the other way around, start with migrating the controllers and continue using Datamapper at first.
I don't think it's a good idea to actually run the partly migrated code in a production environment, but I do like to migrate in a structured way so I can solve one problem at a time.
You can't migrate from DataMapper to ActiveRecord, that is counterproductive. The level of abstraction of DataMapper is way higher than the ActiveRecord's.
However, jumping to Rails you may find lots of sugar using very nice plugins or gems not known for friendship with Sinatra.
Try searching for gems that claims framework agnostic support and depends on just Rack and/or ActiveModel, not Rails.
MongoDB has two popular ORMs for Rails: MongoID and MongoMapper.
Are there CouchDB ORM:s for Rails 3?
I can't say for sure since I've never used it, but it looks like CouchRest would be the way to go - specifically "CouchRest Model" looks like has been updated to work with Rails3 ActiveModel.
FWIW, I landed on CouchRest after finding this thread.
there is couchRest as noted above, or if you like active record style try couch_foo. I had different needs when i was looking into couch this past spring, and using rails 3. Rails 3 should be ORM agnostic, so it shouldn't really mess with it, although I couldn't get testing to work easily, but that could have just been me.
I'm looking for any pointers on how to write a rails web app without ActiveRecord.
A doc or an example of a (not too complex) web app using storage backends other than a relational database would be greatly appreciated.
It's not clear on what should be implemented in the model classes in order to make the rails app work without the ActiveRecord layer.
Thanks,
Of course it's possible, here, for example, MongoMapper is used instead of ActiveRecord:
http://railstips.org/blog/archives/2009/07/23/getting-started-with-mongomapper-and-rails/
Note that this will seem a lot easier with Rails 3. Rails team spent a lot of efforts on ORM agnosticism when pushing to beta. They've created a public API (ActiveModel) for different ORMs to implement, so that an ORM can serve as a drop-in replacement for ActiveRecord. That way you'll just be able to define models in terms of your ORM without any extra efforts.
DataMapper already has an implementation of ActiveModel in dm-rails, and there'll be more to come.
See this post by Yehuda Katz for details.
I have a small web application that is currently running on Sinatra. It only has two pages so I don't really need controllers or many views. I have included ActiveRecord to interact with a database and ActiveMailer to send and receive mail.
Would it be worth it to use Rails, or Merb on a project as small as this? I find myself adding features that are included in Rails. I haven't had any experience with Merb before so I don't really know if that would be a suitable option. But from what I hear Merb may be the way to go on a project that only needs a few components.
Thanks.
No need to switch to Rails if your already running on Sinatra for a small project. You can use ActiveRecord and ActiveMailer outside of Rails.
Merb is merging with Rails for Rails version 3.0. As part of this process, the core Rails architecture is going to be "merbified" so as to be more easily configured to only use the particular components you need.
There may going to be a point as your application grows that you find yourself reinventing features that already exists, in this case I would consider switching frameworks.
Personally, I use Rails even for quite small projects. It means I have a single framework and deployment environment for everything that I work on.
I use Sinatra often for stuff much bigger than what you describe. What features of Rails do you find you are needing to add? If it's just stuff like 5.hours.ago and stuff, you could always: a) pull that part of the code out of activesupport and paste it into a 'common'/similar file in your project or b) just require activesupport and use it's features.