diff --git a/app/controllers/annotations_controller.rb b/app/controllers/annotations_controller.rb index e75581d45..233275bdf 100644 --- a/app/controllers/annotations_controller.rb +++ b/app/controllers/annotations_controller.rb @@ -6,14 +6,14 @@ class AnnotationsController < ApplicationController @annotation = Annotation.new(annotation_params) @annotation.user = current_user if @annotation.save - render json: @annotation.to_json + render json: @annotation.to_json(methods: :permissions) end end def update @annotation = Annotation.find!(params[:id]) if @annotation.update_attributes(annotation_params) - render json: @annotation.to_json + render json: @annotation.to_json(methods: :permissions) end end @@ -26,7 +26,7 @@ class AnnotationsController < ApplicationController def search @annotations = Annotation.where(legislation_id: params[:legislation_id]) annotations_hash = { total: @annotations.size, rows: @annotations } - render json: annotations_hash.to_json + render json: annotations_hash.to_json(methods: :permissions) end private @@ -37,4 +37,4 @@ class AnnotationsController < ApplicationController .permit(:quote, :text, ranges: [:start, :startOffset, :end, :endOffset]) .merge(legislation_id: params[:legislation_id]) end -end \ No newline at end of file +end diff --git a/app/models/annotation.rb b/app/models/annotation.rb index 504232c36..32e39903a 100644 --- a/app/models/annotation.rb +++ b/app/models/annotation.rb @@ -3,4 +3,8 @@ class Annotation < ActiveRecord::Base belongs_to :legislation belongs_to :user -end \ No newline at end of file + + def permissions + { update: [user_id], delete: [user_id] } + end +end