1 class Orvos::V1::CollectionsController < ApplicationController
3 # GET /collections.json
5 @collections = Collection.all
8 :kind => "orvos#collectionList",
11 :next_page_token => "",
13 :items => @collections.map { |collection| collection }
15 respond_to do |format|
16 format.json { render json: @collectionlist }
21 # GET /collections/1.json
23 @collection = Collection.find(params[:id])
25 respond_to do |format|
26 format.html # show.html.erb
27 format.json { render json: @collection }
31 # GET /collections/new
32 # GET /collections/new.json
34 @collection = Collection.new
36 respond_to do |format|
37 format.html # new.html.erb
38 format.json { render json: @collection }
42 # GET /collections/1/edit
44 @collection = Collection.find(params[:id])
48 # POST /collections.json
50 if params[:collection].class == String
51 @collection = Collection.new(JSON.parse(params[:collection]))
53 @collection = Collection.new(params[:collection])
56 respond_to do |format|
58 format.html { redirect_to @collection, notice: 'Collection was successfully created.' }
59 format.json { render json: @collection, status: :created, location: @collection }
61 format.html { render action: "new" }
62 format.json { render json: @collection.errors, status: :unprocessable_entity }
68 # PUT /collections/1.json
70 @collection = Collection.find(params[:id])
72 respond_to do |format|
73 if @collection.update_attributes(params[:collection])
74 format.html { redirect_to @collection, notice: 'Collection was successfully updated.' }
75 format.json { head :ok }
77 format.html { render action: "edit" }
78 format.json { render json: @collection.errors, status: :unprocessable_entity }
83 # DELETE /collections/1
84 # DELETE /collections/1.json
86 @collection = Collection.find(params[:id])
89 respond_to do |format|
90 format.html { redirect_to collections_url }
91 format.json { head :ok }