How can I validate the uniqueness of a full name in rails 3.2?
class User < ActiveRecord::Base
attr_accessible :first_name, :last_name
validates :name, :uniqueness => true
def name
[first_name, last_name].join(' ')
end
end
When I run rspec the test fails with this error.
1) User has a first name
Failure/Error: before { @user = FactoryGirl.create(:user) }
NoMethodError:
undefined method `text?' for nil:NilClass
Solution 1:
Solution 2: