Created
November 11, 2010 10:36
-
-
Save solnic/672322 to your computer and use it in GitHub Desktop.
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
| #!/usr/bin/env ruby | |
| # | |
| # encoding: utf-8 | |
| require 'dm-sqlite-adapter' | |
| require 'dm-migrations' | |
| require 'dm-validations' | |
| DataMapper.setup :default, "sqlite::memory:" | |
| class Ban | |
| include DataMapper::Resource | |
| property :id, Serial | |
| belongs_to :user # required by default | |
| has n, :users, :through => Resource | |
| end | |
| class User | |
| include DataMapper::Resource | |
| property :id, Serial | |
| end | |
| DataMapper.finalize | |
| DataMapper.auto_migrate! | |
| b = Ban.new | |
| puts b.valid? | |
| puts b.errors[:user_id].inspect |
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
| false | |
| ["User must not be blank"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment