Skip to content
Snippets Groups Projects
Commit 2fb0ab22 authored by Mateus Rambo Strey's avatar Mateus Rambo Strey
Browse files

fix collection creation

parent cc528411
No related branches found
No related tags found
No related merge requests found
......@@ -6,10 +6,9 @@ class V1::CollectionsController < ApplicationController
include ::HighlightsController
include ::Paginator
before_action :authenticate_user!, only: [:create, :update, :destroy]
before_action :set_collection, only: [:show, :update, :destroy, :add_object, :delete_object]
before_action :set_new_collection, only: :index
before_action :authenticate_user!, only: [:create, :update, :destroy]
before_action :authorize!, except: [:create, :tagging, :untagging]
# GET /v1/collections
......@@ -29,8 +28,9 @@ class V1::CollectionsController < ApplicationController
# POST /v1/collection.json
def create
collection = Collection.new(collection_params)
collection.owner = current_user if collection.owner.nil?
authorize collection
if collection.save
collection_associations(collection)
render json: collection, status: :created
......@@ -42,7 +42,6 @@ class V1::CollectionsController < ApplicationController
# PUT/PATCH /v1/users/1
# PUT/PATCH /v1/users/1.json
def update
if @collection.update(collection_params)
@collection.add_items(extra_params[:items])
render json: @collection, status: :ok
......@@ -111,5 +110,4 @@ class V1::CollectionsController < ApplicationController
def authorize!
authorize @collection
end
end
......@@ -32,7 +32,7 @@ class CollectionPolicy < ApplicationPolicy
end
def create?
record if user_exists?
record if owns?
end
def show?
......
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