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 hidden or 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 hidden or 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") |
Thanks @dukbb, I have fixed that.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jingweno you probably want a comma after the
n
on line 7.