- require 'dm-core'
- require 'dm-migrations'
- require 'dm-validations'
- DataMapper::Logger.new($stdout, :debug)
- DataMapper.setup(:default, 'mysql://root@localhost/test')
- module Camino
- module Business
- class Branch
- include DataMapper::Resource
- property :id, Serial
- has n, :business_years, 'Camino::Business::Year'
- end
- class Year
- include DataMapper::Resource
- property :start, Date, :required => true, :unique => :years
- property :stop, Date, :required => true, :unique => :years
- belongs_to :branch, 'Camino::Business::Branch', :key => true
- end
- end
- end
- DataMapper.finalize.auto_migrate!
- Camino::Business::Branch.create :business_years => [
- Camino::Business::Year.new(:start => Date.today, :stop => Date.today + 150)
- ]
- __END__
- ree-1.8.7-2010.02 mungo:camino_surf snusnu$ bundle exec ruby foo.rb
- ~ (0.000098) SET sql_auto_is_null = 0
- ~ (0.000078) SET SESSION sql_mode = 'ANSI,NO_BACKSLASH_ESCAPES,NO_DIR_IN_CREATE,NO_ENGINE_SUBSTITUTION,NO_UNSIGNED_SUBTRACTION,TRADITIONAL'
- ~ (0.001577) DROP TABLE IF EXISTS `camino_business_branches`
- ~ (0.000253) SHOW TABLES LIKE 'camino_business_branches'
- ~ (0.000083) SET sql_auto_is_null = 0
- ~ (0.000084) SET SESSION sql_mode = 'ANSI,NO_BACKSLASH_ESCAPES,NO_DIR_IN_CREATE,NO_ENGINE_SUBSTITUTION,NO_UNSIGNED_SUBTRACTION,TRADITIONAL'
- ~ (0.000306) SHOW VARIABLES LIKE 'character_set_connection'
- ~ (0.000289) SHOW VARIABLES LIKE 'collation_connection'
- ~ (0.141534) CREATE TABLE `camino_business_branches` (`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY(`id`)) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci
- ~ (0.002576) DROP TABLE IF EXISTS `camino_business_years`
- ~ (0.000297) SHOW TABLES LIKE 'camino_business_years'
- ~ (0.194693) CREATE TABLE `camino_business_years` (`start` DATE NOT NULL, `stop` DATE NOT NULL, `branch_id` INT(10) UNSIGNED NOT NULL, PRIMARY KEY(`branch_id`)) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci
- ~ (0.136234) CREATE INDEX `index_camino_business_years_branch` ON `camino_business_years` (`branch_id`)
- ~ (0.143769) CREATE UNIQUE INDEX `unique_camino_business_years_years` ON `camino_business_years` (`start`, `stop`)
- ~ (0.001048) INSERT INTO `camino_business_branches` () VALUES ()
- /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-validations-1211e58/lib/dm-validations/validators/uniqueness_validator.rb:36:in `__send__': undefined method `years' for #<Camino::Business::Year:0x101e7e468> (NoMethodError)
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-validations-1211e58/lib/dm-validations/validators/uniqueness_validator.rb:36:in `valid?'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-validations-1211e58/lib/dm-validations/validators/uniqueness_validator.rb:36:in `each'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-validations-1211e58/lib/dm-validations/validators/uniqueness_validator.rb:36:in `valid?'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-validations-1211e58/lib/dm-validations/validators/uniqueness_validator.rb:19:in `call'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-validations-1211e58/lib/dm-validations/contextual_validators.rb:58:in `execute'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-validations-1211e58/lib/dm-validations/contextual_validators.rb:57:in `map'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-validations-1211e58/lib/dm-validations/contextual_validators.rb:57:in `execute'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-validations-1211e58/lib/dm-validations.rb:137:in `valid?'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-validations-1211e58/lib/dm-validations.rb:108:in `save_self'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-core-75c67e6/lib/dm-core/resource.rb:1018:in `_save'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-core-75c67e6/lib/dm-core/resource.rb:1234:in `run_once'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-core-75c67e6/lib/dm-core/resource.rb:1017:in `_save'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-core-75c67e6/lib/dm-core/resource.rb:417:in `save'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-validations-1211e58/lib/dm-validations.rb:96:in `save'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-validations-1211e58/lib/dm-validations/support/context.rb:30:in `validation_context'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-validations-1211e58/lib/dm-validations.rb:96:in `save'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-core-75c67e6/lib/dm-core/collection.rb:1241:in `__send__'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-core-75c67e6/lib/dm-core/collection.rb:1241:in `_save'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/gems/data_objects-0.10.2/lib/data_objects/connection.rb:136:in `all?'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-core-75c67e6/lib/dm-core/collection.rb:1241:in `each'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-core-75c67e6/lib/dm-core/collection.rb:1241:in `all?'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-core-75c67e6/lib/dm-core/collection.rb:1241:in `_save'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-core-75c67e6/lib/dm-core/associations/one_to_many.rb:274:in `_save'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-core-75c67e6/lib/dm-core/collection.rb:873:in `save'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-core-75c67e6/lib/dm-core/resource.rb:1066:in `__send__'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-core-75c67e6/lib/dm-core/resource.rb:1066:in `save_children'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-core-75c67e6/lib/dm-core/resource.rb:1065:in `map'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-core-75c67e6/lib/dm-core/resource.rb:1065:in `save_children'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-core-75c67e6/lib/dm-core/resource.rb:1018:in `_save'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-core-75c67e6/lib/dm-core/resource.rb:1234:in `run_once'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-core-75c67e6/lib/dm-core/resource.rb:1017:in `_save'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-core-75c67e6/lib/dm-core/resource.rb:417:in `save'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-validations-1211e58/lib/dm-validations.rb:96:in `save'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-validations-1211e58/lib/dm-validations/support/context.rb:30:in `validation_context'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-validations-1211e58/lib/dm-validations.rb:96:in `save'
- from /Users/snusnu/.rvm/gems/ree-1.8.7-2010.02/bundler/gems/dm-validations-1211e58/lib/dm-validations.rb:81:in `create'
- from foo.rb:36