Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Comparison between the DataMapper gem and the ActiveRecord gem
class Store < ActiveRecord::Base
has_many :products
belongs_to :user
validates_presence_of :name
end
> Store.create(:name => "Amazon")
> Store.where(:name => "Amazon")
class Store
include DataMapper::Resource
property :id, Serial
property :name, String
has n, :products
belongs_to :user
validates_presence_of :name
end
> Store.create(:name => "Apple")
> Store.all(:name => "Apple")
Owner

jingweno commented Sep 28, 2011

As you may see, the datamapper gem and the activerecord gem are both an implementation of the Active Record pattern (http://martinfowler.com/eaaCatalog/activeRecord.html).

dkubb commented Oct 10, 2011

@jingweno you probably want a comma after the n on line 7.

Owner

jingweno commented Oct 10, 2011

Thanks @dukbb, I have fixed that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment