Class: ContentFoldersController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/content_folders_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /content_folder POST /content_folder.json



41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/content_folders_controller.rb', line 41

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

#indexObject



12
13
14
15
16
17
18
19
# File 'app/controllers/content_folders_controller.rb', line 12

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

#showObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/content_folders_controller.rb', line 23

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