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

adding user as tagger

parent 2f951662
No related branches found
No related tags found
No related merge requests found
......@@ -8,9 +8,7 @@ module TaggableController
# POST /v1/learning_objects/1/tagging
# POST /v1/learning_objects/1/tagging.json
def tagging
taggable.tag_list.add(tag_params[:name])
if taggable.save
if current_user.tag(taggable, with: taggable.owner_tags_on(current_user, :tags) << tag_params[:name], on: :tags)
render json: @taggable, status: :created
else
render json: @taggable.errors, status: :unprocessable_entity
......@@ -20,9 +18,7 @@ module TaggableController
# DELETE /v1/learning_objects/1/untagging
# DELETE /v1/learning_objects/1/untagging.json
def untagging
taggable.tag_list.remove(params[:name])
if taggable.save
if current_user.tag(taggable, with: taggable.owner_tags_on(current_user, :tags).delete(tag_params[:name]), on: :tags)
render json: @taggable, status: :ok
else
render json: @taggable.errors, status: :unprocessable_entity
......
......@@ -71,6 +71,8 @@ class User < ActiveRecord::Base
validates_attachment_content_type :avatar, content_type: /\Aimage\/.*\Z/
validates :terms_of_service, acceptance: true
acts_as_tagger
searchkick language: 'brazilian', match: :word_start, searchable: [:name], callbacks: :async
def search_data
......
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