Class: Iron::Api::ContentController
Constant Summary
Iron::Api::CursorPagination::DEFAULT_PER_PAGE, Iron::Api::CursorPagination::MAX_PER_PAGE
Instance Method Summary
collapse
Instance Method Details
#create ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/controllers/iron/api/content_controller.rb', line 23
def create
@entry = @content_type.entries.build
@entry.route = params[:route] if params.key?(:route)
@entry.assign_content(content_params)
if @entry.save
render :show, status: :created, location: api_content_url(handle: @content_type.handle, id: @entry.id)
else
render json: @entry.content_errors, status: :unprocessable_entity
end
end
|
#destroy ⇒ Object
46
47
48
49
|
# File 'app/controllers/iron/api/content_controller.rb', line 46
def destroy
@entry.destroy!
head :no_content
end
|
#index ⇒ Object
11
12
13
14
15
16
17
18
|
# File 'app/controllers/iron/api/content_controller.rb', line 11
def index
if params.key?(:route)
@entry = @content_type.entries.find_by!(route: params[:route])
render :show
else
@collection = paginate(@content_type.entries)
end
end
|
#show ⇒ Object
20
21
|
# File 'app/controllers/iron/api/content_controller.rb', line 20
def show
end
|
#update ⇒ Object
35
36
37
38
39
40
41
42
43
44
|
# File 'app/controllers/iron/api/content_controller.rb', line 35
def update
@entry.route = params[:route] if params.key?(:route)
@entry.assign_content(content_params)
if @entry.save
render :show
else
render json: @entry.content_errors, status: :unprocessable_entity
end
end
|