Skip to content
Snippets Groups Projects
Commit 533c3945 authored by Giovanne Marcelo's avatar Giovanne Marcelo
Browse files

[WIP]fix learning object create

parent 3fc3844f
No related branches found
No related tags found
No related merge requests found
......@@ -4,9 +4,10 @@ class LearningObject::DraftBuilder
@draft = LearningObject.new(sanitize_params(params))
@draft.draft
# build topics
params[:topics].try(:each) do |t|
@draft.topics << Topic.find(t)
# build tags
#
params[:tags].try(:each) do |t|
@draft.tags << Tag.find(t['id'])
end
#build language
......@@ -21,7 +22,7 @@ class LearningObject::DraftBuilder
def self.sanitize_params(args={})
_args = args.clone
%w(topics language link).each do |arg|
%w(tags language link).each do |arg|
_args.delete(arg)
end
metadata = [{'key' => 'dc.object.url', 'value' => args[:link]}]
......
......@@ -35,10 +35,10 @@ class LearningObjectBuilder
_params = params.clone
_params.delete :link
# build topics
_params[:topics] = []
params[:topics].try(:each) do |t|
_params[:topics] << Topic.find(t)
# build tags
_params[:tags] = []
params[:tags].try(:each) do |t|
_params[:tags] << Tag.find(t['id'])
end
#build language
......
......@@ -68,6 +68,6 @@ class V1::CollectionsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def collection_params
params.require(:collection).permit(:name, :description, :owner_id, :owner_type, :privacy, :tag, learning_objects: [])
params.require(:collection).permit(:name, :description, :owner_id, :owner_type, :privacy, tags: [], learning_objects: [])
end
end
......@@ -66,7 +66,7 @@ class V1::LearningObjectsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def learning_object_params
params[:learning_object].permit(:author, :name, :object_type_id, :description, :school_level, :language, :link, :tags)
params[:learning_object].permit(:author, :name, :object_type_id, :description, :school_level, :language, :link, tags: [:id] )
end
def authorize!
......
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