Class: Api::V1::Domains::RecordsController

Inherits:
ApiController
  • Object
show all
Includes:
DomainAuthorization
Defined in:
app/controllers/api/v1/domains/records_controller.rb

Instance Method Summary collapse

Methods included from DomainAuthorization

#authorize_domain, #current_domain

Instance Method Details

#createObject



16
17
18
19
# File 'app/controllers/api/v1/domains/records_controller.rb', line 16

def create
  @record = Record.create(domain_id: current_domain.id, name: params["name"], type: params["type"], content: params["content"], ttl: params["ttl"], priority: params["priority"]) # standard:disable all
  render "show"
end

#destroyObject



39
40
41
42
43
44
45
46
# File 'app/controllers/api/v1/domains/records_controller.rb', line 39

def destroy
  @record = Record.find(params[:id])

  @record.destroy! #standard:disable all

  index
  render "index"
end

#indexObject



12
13
14
# File 'app/controllers/api/v1/domains/records_controller.rb', line 12

def index
  @records = current_domain.records
end

#showObject



21
22
23
# File 'app/controllers/api/v1/domains/records_controller.rb', line 21

def show
  @record = Record.find(params[:id])
end

#updateObject



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/api/v1/domains/records_controller.rb', line 25

def update
  @record = Record.find(params[:id])

  (@record.type = params[:type]) if params[:type]
  (@record.name = params[:name]) if params[:name]
  (@record.content = params[:content]) if params[:content]
  (@record.ttl = params[:ttl]) if params[:ttl]
  (@record.priority = params[:priority]) if params[:priority]

  @record.save # standard:disable all

  render "show"
end