3
마이그레이션대량 할당 레일에 3.2.3
을 특성을 보호 할 수 없습니다class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.string :password_digest
t.timestamps
end
end
end
모델
class User < ActiveRecord::Base
attr_accessible :name, :password_digest
validates :name, :presence => true, :uniqueness => true
has_secure_password
end
사용자 등록 _form
.main_form
= form_for @user do |f|
%div
= f.label :name
= f.text_field :name, :size=>40
%div
= f.label :password, "Password"
= f.password_field :password
%div
= f.label :password_confirmation, "Confirmation"
= f.password_field :password_field
%div
= f.submit 'Create user'
나는 새로운 사용자를 등록하려고 예외가 throw됩니다.
ActiveModel::MassAssignmentSecurity::Error in UsersController#create
Can't mass-assign protected attributes: password, password_field
내가 뭘 잘못 했니?
어떤 파일을 추가해야합니까? – Alexandre
죄송 합니다만, 'User' 모델에 있어야한다는 것을 잊어 버렸습니다. 'attr_accessible' 라인을 광산으로 바꾸면 작동 할 것입니다. – Matzi