Class: RdeTemplatesController

Inherits:
ApplicationController show all
Defined in:
frontend/app/controllers/rde_templates_controller.rb

Instance Method Summary (collapse)

Methods inherited from ApplicationController

can_access?, permission_mappings, set_access_control

Instance Method Details

- (Object) batch_delete



37
38
39
40
41
42
43
44
45
46
# File 'frontend/app/controllers/rde_templates_controller.rb', line 37

def batch_delete

  params[:ids].each do |id|
    template = JSONModel(:rde_template).find(id)
    template.delete
  end

  redirect_to :action => 'index'
  
end

- (Object) create



6
7
8
9
10
11
12
13
# File 'frontend/app/controllers/rde_templates_controller.rb', line 6

def create
  template = JSONModel(:rde_template).from_hash(params['template'])

  id = template.save

  render :json => {id: id}

end

- (Object) index



16
17
18
19
20
21
22
23
24
25
26
27
# File 'frontend/app/controllers/rde_templates_controller.rb', line 16

def index
  templates = JSONModel(:rde_template).all.map do |template|
    {
      :name => template.name,
      :id => template.id,
      :record_type => template.record_type
    }
  end

  render :json => templates

end

- (Object) show



30
31
32
33
34
# File 'frontend/app/controllers/rde_templates_controller.rb', line 30

def show
  template = JSONModel(:rde_template).find(params[:id])

  render :json => template
end