@panel = Panel.edit(params[:id], @author)
respond_to do |format|
Panel.transaction do
- @panel.destroy
- format.html { redirect_to panels_url }
- format.json { head :ok }
+ if @panel.destroy_with_elements
+ flash[:notice] = I18n.t('flash.notice.destroyed', :model => Panel.model_name.human)
+ format.html { redirect_to '/home/panel' }
+ format.json { head :ok }
+ else
+ flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => Panel.model_name.human)
+ format.html { redirect_to @panel }
+ format.json { render json: @panel.errors, status: :unprocessable_entity }
+ end
end
end
end