Class: Locomotive::Api::ContentEntriesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/locomotive/api/content_entries_controller.rb

Instance Method Summary collapse

Methods included from Locomotive::ActionController::LocaleHelpers

#back_to_default_site_locale, #current_content_locale, #localized?, #set_back_office_locale, #set_current_content_locale, #setup_i18n_fallbacks

Instance Method Details

#createObject



17
18
19
20
21
22
# File 'app/controllers/locomotive/api/content_entries_controller.rb', line 17

def create
  @content_entry = @content_type.entries.build
  @content_entry_presenter = @content_entry.to_presenter
  @content_entry_presenter.update_attributes(params[:content_entry])
  respond_with @content_entry, :location => main_app.locomotive_api_content_entries_url(@content_type.slug)
end

#destroyObject



31
32
33
34
35
# File 'app/controllers/locomotive/api/content_entries_controller.rb', line 31

def destroy
  @content_entry = @content_type.entries.find(params[:id])
  @content_entry.destroy
  respond_with @content_entry, :location => main_app.locomotive_api_content_entries_url(@content_type.slug)
end

#indexObject



7
8
9
10
# File 'app/controllers/locomotive/api/content_entries_controller.rb', line 7

def index
  @content_entries = @content_type.ordered_entries
  respond_with @content_entries
end

#showObject



12
13
14
15
# File 'app/controllers/locomotive/api/content_entries_controller.rb', line 12

def show
  @content_entry = @content_type.entries.any_of({ :_id => params[:id] }, { :_slug => params[:id] }).first
  respond_with @content_entry, :status => @content_entry ? :ok : :not_found
end

#updateObject



24
25
26
27
28
29
# File 'app/controllers/locomotive/api/content_entries_controller.rb', line 24

def update
  @content_entry = @content_type.entries.find(params[:id])
  @content_entry_presenter = @content_entry.to_presenter
  @content_entry_presenter.update_attributes(params[:content_entry])
  respond_with @content_entry, :location => main_app.locomotive_api_content_entries_url(@content_type.slug)
end