Skip to content

Instantly share code, notes, and snippets.

@solnic
Created September 9, 2010 16:28
Show Gist options
  • Select an option

  • Save solnic/572105 to your computer and use it in GitHub Desktop.

Select an option

Save solnic/572105 to your computer and use it in GitHub Desktop.
ruby-1.9.2-p0 > u = User.first
=> #<User ...
ruby-1.9.2-p0 > u.children_valid?
=> true
ruby-1.9.2-p0 > u.user_roles << UserRole.new
=> [#<UserRole @user_id=1 @role_id=10 @division_id=7>, #<UserRole @user_id=1 @role_id=nil @division_id=nil>]
ruby-1.9.2-p0 > u.children_valid?
=> false
ruby-1.9.2-p0 > u.errors[:user_roles]
=> [#<DataMapper::Validations::ValidationErrors:0xa647e90 @resource=#<UserRole @user_id=1 @role_id=nil @division_id=nil>, @errors={:role_id=>["Role can't be blank"], :division_id=>["Division can't be blank"]}>]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment