I have many topics about this issue and still I am not able to understand what I am doing wrong:
I have two models, with the following relations:
securty_user_rb:
attr_accessible ...(some fields)
:security_users_detail
has_one :security_users_detail, dependent: :destroy
security_users_detail.rb
attr_accessible ...(some fields)
belongs_to :security_user
and in the security_users_controlller.rb I am doing this in the new action:
@security_user = SecurityUser.new(params[:security_user])
@security_user.build_security_users_detail(security_users_detail: SecurityUsersDetail.new)
Why I am not able to build the connection and I am getting
Can't mass-assign protected attributes: security_users_detail
error as I have attr_accessible:security_users_detail in the model?
EDIT:
I have try to comment the following line in my applicatin.rb file in order to check if the issue will be resolved:
config.active_record.whitelist_attributes = true
Unfortunately, I am getting the same error again (after restarting the server), so I suppose my problem is connected with some other thing.
The whole problem was caused by a validations in my details model - I have validations that are checking both the format and the presence of some of the fields, so apparently rails did not allowed me to created object with empty fields.
To fix this I have to used validate:false.
I have lost a lot of time reading about rails defaults like
config.active_record.whitelist_attributes = true
and the use of attr_accessible, but it seems that failed validations can threw the same
Can't mass-assign protected attributes
error.