Skip to content
Snippets Groups Projects
Commit e2665a14 authored by Mauricio Giacomini Girardello's avatar Mauricio Giacomini Girardello
Browse files

adding remove learning object from collection route and controller action

parent 4ba9fd6e
No related branches found
No related tags found
No related merge requests found
......@@ -64,10 +64,20 @@ class CollectionsController < ApplicationController
def add_learning_object
learning_object = learning_object_repository.find params[:learning_object_id]
@collection.add learning_object
collection_repository.save_learning_objects @collection
if request.xhr? && collection_repository.save_learning_objects(@collection)
render json: {status: true}
end
end
# DELETE /collections/1/learning_object/43
def remove_learning_object
#learning_object = learning_object_repository.find params[:learning_object_id]
#@collection.add learning_object
#collection_repository.save_learning_objects @collection
if request.xhr?
render json: {collections: @collection.learning_objects.as_json}
render json: {status: true}
end
end
......
......@@ -49,6 +49,9 @@ Rails.application.routes.draw do
member do
# add a learning object for some collection
post '/learning_object/:learning_object_id', as: :add_learning_object, action: :add_learning_object
# remove a learning object for some collection
delete '/learning_object/:learning_object_id', as: :destroy_learning_object, action: :remove_learning_object
end
end
......@@ -66,7 +69,6 @@ Rails.application.routes.draw do
get '/autocomplete' => 'search#autocomplete'
get '/subject/:id' => 'welcome#subject', as: 'subject_index'
get '/collection' => 'welcome#collection'
get '/add_file' => 'welcome#add_file'
get '/signup' => 'welcome#signup'
get '/follow_collection' => 'welcome#follow_collection'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment