ActiveModel::MassAssignmentSecurity::Error: Can't mass-assign protected attributes
问题 If I try to execute the following code: hassle = rota.hassles.create(:sender => user1, :receiver => user2, :type => "sms") I obain the following error: Failure/Error: hassle = rota.hassles.create(:sender => user1, :receiver => user2, :type => "sms") ActiveModel::MassAssignmentSecurity::Error: Can't mass-assign protected attributes: type I am not sure what this means. I have made the :type to be compulsory, so if I do remove it, I get an sql error. 回答1: A couple things: Mass Assignment usually