Created
December 21, 2009 19:52
-
-
Save smerritt/261185 to your computer and use it in GitHub Desktop.
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
dm_version = '=0.10.2' | |
gem 'dm-core', dm_version | |
gem "dm-aggregates", dm_version | |
gem "dm-migrations", dm_version | |
gem "dm-timestamps", dm_version | |
gem "dm-types", dm_version | |
gem "dm-validations", dm_version | |
gem "data_objects", '=0.10' | |
gem "do_sqlite3", '=0.10' |
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
#!/usr/bin/env ruby | |
require 'vendor/gems/environment' | |
Bundler.require_env | |
DataMapper.setup(:default, 'sqlite3:///tmp/bs.db') | |
class Sheep | |
include DataMapper::Resource | |
property :id, Serial | |
property :name, String | |
has n, :hooves | |
end | |
class Hoof | |
include DataMapper::Resource | |
property :id, Serial | |
property :position, String | |
belongs_to :sheep | |
end | |
DataMapper.auto_migrate! | |
s = Sheep.new(:name => 'Shaun') | |
h = s.hooves.new(:position => 'left-front') | |
h.valid? # ==> false; the error is {:sheep_id=>["Sheep must not be blank"]} | |
h.save # ==> true; shouldn't this fail due to validations? | |
h.valid? # ==> true; so invalid -> save anyway -> valid? confused now. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment