Skip to content
Snippets Groups Projects
Commit 88209fc3 authored by Bernardo Chagas's avatar Bernardo Chagas
Browse files

Create concern collector for User and Institution

parent 7395d0d4
No related branches found
No related tags found
No related merge requests found
module CollectorController
extend ActiveSupport::Concern
included do
before_action :set_collection, only: :show
end
# GET /v1/users/1/collections
def index
render json: Collection.where(collector: collector)
end
# GET /v1/user/1/collections/1
def show
render json: @collection
end
protected
def collector
raise NotImplementedError
#user, id = request.path.split('/')[2, 3]
#collector_model = user.singularize.classify.constantize
#@collector = collector_model.find(id)
end
def set_collection
@collection ||= Collection.find(params[:id])
end
end
module Collector
extend ActiveSupport::Concern
included do
has_many :collections, as: :collector, dependent: :destroy
end
end
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