app/controllers/spotlight/roles_controller.rb in blacklight-spotlight-0.16.0 vs app/controllers/spotlight/roles_controller.rb in blacklight-spotlight-0.17.0
- old
+ new
@@ -19,12 +19,10 @@
end
def update_all
authorize_nested_attributes! exhibit_params[:roles_attributes], Role
- any_deleted = exhibit_params[:roles_attributes].values.any? { |item| item['_destroy'].present? }
-
if @exhibit.update(exhibit_params)
notice = any_deleted ? t(:'helpers.submit.role.destroyed') : t(:'helpers.submit.role.updated')
redirect_to exhibit_roles_path(@exhibit), notice: notice
else
flash[:alert] = t(:'helpers.submit.role.batch_error')
@@ -34,9 +32,15 @@
protected
def exhibit_params
params.require(:exhibit).permit(roles_attributes: [:id, :user_key, :role, :_destroy])
+ end
+
+ def any_deleted
+ exhibit_params[:roles_attributes].values.any? do |item|
+ item['_destroy'].present? && item['_destroy'] != 'false'
+ end
end
# When nested attributes are passed in, ensure we have authorization to update each row.
# @param attr [Hash,Array] the nested attributes
# @param klass [Class] the class that is getting created