Class: Landable::Api::TemplatesController

Inherits:
Landable::ApiController show all
Defined in:
app/controllers/landable/api/templates_controller.rb

Constant Summary

Constants inherited from Landable::ApiController

Landable::ApiController::API_MEDIA_REGEX

Instance Method Summary collapse

Methods inherited from Landable::ApiController

#api_media

Instance Method Details

#createObject

RESTful methods



10
11
12
13
14
15
# File 'app/controllers/landable/api/templates_controller.rb', line 10

def create
  template = Template.new(template_params)
  template.save!
  
  respond_with template, status: :created, location: template_url(template)
end

#destroyObject



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

def destroy
  @template.temp_author = current_author
  @template.try(:deactivate)

  respond_with @template
end

#indexObject



24
25
26
# File 'app/controllers/landable/api/templates_controller.rb', line 24

def index
  respond_with Template.all
end

#publishObject

custom methods



39
40
41
42
43
# File 'app/controllers/landable/api/templates_controller.rb', line 39

def publish
  @template.publish! author_id: current_author.id, notes: params[:notes], is_minor: !!params[:is_minor]
  
  respond_with @template
end

#reactivateObject



45
46
47
48
49
# File 'app/controllers/landable/api/templates_controller.rb', line 45

def reactivate
  @template.try(:reactivate)
  
  respond_with @template
end

#showObject



28
29
30
# File 'app/controllers/landable/api/templates_controller.rb', line 28

def show
  respond_with @template
end

#updateObject



32
33
34
35
36
# File 'app/controllers/landable/api/templates_controller.rb', line 32

def update
  @template.update_attributes!(template_params)
  
  respond_with @template
end