Я хочу уничтожить документы из отношения embeds_many
, используя атрибут запроса.
class Experience
include Mongoid::Document
embeds_many :variations, class_name: 'ExperienceVariation'
accepts_nested_attributes_for :variations, allow_destroy: true
end
class ExperiencesController < ApplicationController
def update
if @experience.update_attributes(experience_params)
show
else
render json: @experience.andand.errors, status: :unprocessable_entity
end
end
def experience_params
params.require(:experience).permit(
...
variations: [
:id, :delete, ...
]
)
end
end
При выполнении запроса с помощью _destroy
я получаю сообщение об ошибке:
Mongoid::Errors::UnknownAttribute -
Problem:
Attempted to set a value for '_destroy' which is not allowed on the model ExperienceVariation.
Как заставить работать вложенный _destroy
?