我有模型:
class User < ActiveRecord::Base
attr_accessible :login,
:password,
:email,
:first_name,
:middle_name,
:last_name,
:phone
end
但是,我有一个问题=>
undefined method `first_name=' for #<User:0xa604c30>
...
test/functional/users_controller_test.rb:5:in `block in <class:UsersControllerTest>'
...
错误文件 test/functional/users_controller_test.rb
require 'test_helper'
class UsersControllerTest < ActionController::TestCase
setup do
@user = create :user
end
...
FactoryGirl 文件 test/factories/users/rb
FactoryGirl.define do
factory :user do
login
password
first_name "MyString"
...
end
end