Sha256: 82962f1fbe13786ab97a4b8c278c6c954c5de6d698c5d0844b4cddaa162e904e

Contents?: true

Size: 1.45 KB

Versions: 6

Compression:

Stored size: 1.45 KB

Contents

require 'jbuilder'

class ContentFoldersController < ApplicationController
  respond_to :json

  rescue_from 'Mongoid::Errors::DocumentNotFound' do |exception|
    render json: {errors: [exception.message]}, status: 404
  end

  # GET http://localhost:3000/content_folders
  # GET http://localhost:3000/content_folders.json
  def index
    @content_folder = ContentFolder.last.child_folders unless ContentFolder.last.nil?
    if @content_folder.nil?
      render json: {}, status: :not_found
    else
      respond_with @content_folder
    end
  end

#GET http://localhost:3000/content_folders/529_lit_center
#GET http://localhost:3000/content_folders/529_lit_center/private_college_529?nested=false
  def show
    path = params[:id]
    nested = params[:nested]

    @content_folder = ContentFolder.find_folder_by_relative_path(path) unless path.nil?
    @nested_view = true
    if (nested=="false")
      @nested_view = false
    end
    if @content_folder.nil?
      render json: {}, status: :not_found
    else
      respond_with @content_folder
    end
  end

  # POST /content_folder
  # POST /content_folder.json
  def create
    content_folder = ContentFolder.new(params[:content_folder])
    old_content_folder = ContentFolder.last
    if content_folder.save
      old_content_folder.delete unless  old_content_folder.nil?
      render json: content_folder, status: :created
    else
      render json: content_folder.errors, status: :unprocessable_entity
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
daengine-0.7.3 app/controllers/content_folders_controller.rb
daengine-0.7.2 app/controllers/content_folders_controller.rb
daengine-0.7.1 app/controllers/content_folders_controller.rb
daengine-0.7 app/controllers/content_folders_controller.rb
daengine-0.6.23 app/controllers/content_folders_controller.rb
daengine-0.6.22 app/controllers/content_folders_controller.rb