When the below test is executed it fails on the last assert with <1> expected but was <0>. How was save unsuccessful, but the count of the associations afterward 0? Thanks. # app/model/user.rb class User < ActiveRecord::Base devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable attr_accessible :email, :password, :password_confirmation, :remember_me has_many :organization_roles has_many :roles, :through => :organization_roles validates :organization_roles, :presence => true accepts_nested_attributes_for :organization_roles def role?(role) return !!self.roles.find_by_name(role.to_s.camelize) end end # test/unit/user_test.rb require ''test_helper'' class UserTest < ActiveSupport::TestCase test "cannot remove all roles" do user = users(:one) assert_equal 1, user.organization_roles.count user.organization_roles.clear assert_false user.save assert_false user.errors[:organization_roles].blank? assert_equal 1, user.reload.organization_roles.count end end -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.