Rails 3 model valid when it should not be
Can someone tell me why my test keeps failing when I try to confirm uniqueness of the email attribute in my model. When I test this in the Rails console, it works correctly, but when I run the unit tests in the console, it fails with this error message:
This is my model:
And here is the unit test that keeps failing:
The reason the unit test keeps fai开发者_运维问答ling is that it says that invalid_user is valid when it shouldn't be. Can someone please help me figure out why this is failing -- it's getting on my nerves that I can't figure it out lol?
Thanks!
Your name
and email
fields should be database fields, not attr_accessor
s. Perhaps you meant to make this attr_accessible
instead?
Try:
:uniqueness => true
I don't see the true part in there.
精彩评论