Created
September 27, 2011 04:36
-
-
Save owenthereal/1244351 to your computer and use it in GitHub Desktop.
Comparison between the DataMapper gem and the ActiveRecord gem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Store < ActiveRecord::Base | |
has_many :products | |
belongs_to :user | |
validates_presence_of :name | |
end | |
> Store.create(:name => "Amazon") | |
> Store.where(:name => "Amazon") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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).