0
'accepts_nested_attributes_for'를 사용하는 양식을 저장하려고 할 때 '보호 된 속성을 대량 지정할 수 없습니다'오류가 발생합니다. 모델을 올바르게 코딩했는데 무엇을 놓쳤는 지 모르겠습니다. 어떤 생각?accepts_nested_attributes_for 오류가 발생했습니다 : 보호 된 속성을 대량 할당 할 수 없습니다.
오류 : 대량 할당 보호 할 수 없습니다 특성 : 조직
user.rb
class User < ActiveRecord::Base
belongs_to :organization
accepts_nested_attributes_for :organization
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
attr_accessible :email, :password, :password_confirmation, :remember_me,
:username, :first_name, :last_name, :organization_attributes
end
organization.rb
class Organization < ActiveRecord::Base
has_many :users
attr_accessible :address1, :address2, :city, :country, :fax, :name, :phone, :state, :zip
end
users_controller.rb
def new
@user = User.new
@organization = Organization.new
respond_to do |format|
format.html # new.html.erb
end
end
def create
@user = User.new(params[:user])
@organization = @user.organizations.build(params[:organization])
respond_to do |format|
if @user.save
@organization.save
format.html { redirect_to @user, notice: 'User was successfully created.' }
else
format.html { render action: "new" }
end
end
end