Class: DocContract::ContractTemplatesController

Inherits:
ApplicationController show all
Includes:
SharedTemplateAndInstanceMethods
Defined in:
app/controllers/doc_contract/contract_templates_controller.rb

Instance Method Summary collapse

Methods included from SharedTemplateAndInstanceMethods

#pdf, #processed_html, #processed_markdown

Methods inherited from ApplicationController

#main

Instance Method Details

#createObject



21
22
23
24
25
26
27
28
29
# File 'app/controllers/doc_contract/contract_templates_controller.rb', line 21

def create
  @record = record_class.new record_params
  authorize! :create, @record
  if @record.save
    redirect_to @record, status: :see_other
  else
    render action: 'new'
  end
end

#destroyObject



51
52
53
54
55
56
# File 'app/controllers/doc_contract/contract_templates_controller.rb', line 51

def destroy
  @record = record_class.find params[:id]
  authorize! :destroy, @record
  @record.destroy
  redirect_to record_class, status: :see_other
end

#editObject



36
37
38
39
# File 'app/controllers/doc_contract/contract_templates_controller.rb', line 36

def edit
  @record = record_class.find(params[:id])
  authorize! :edit, @record
end

#indexObject



8
9
10
11
12
13
14
# File 'app/controllers/doc_contract/contract_templates_controller.rb', line 8

def index
  authorize! :index, record_class
  @q = record_class.ransack query
  @q.sorts = 'name asc' if @q.sorts.empty?
  @records = @q.result.page(params[:page]).per(100)
  respond_with(@records)
end

#newObject



16
17
18
19
# File 'app/controllers/doc_contract/contract_templates_controller.rb', line 16

def new
  @record = record_class.new
  authorize! :create, @record
end

#showObject



31
32
33
34
# File 'app/controllers/doc_contract/contract_templates_controller.rb', line 31

def show
  @record = record_class.find params[:id]
  authorize! :show, @record
end

#updateObject



41
42
43
44
45
46
47
48
49
# File 'app/controllers/doc_contract/contract_templates_controller.rb', line 41

def update
  @record = record_class.find params[:id]
  authorize! :edit, @record
  if @record.update record_params
    redirect_to @record, status: :see_other
  else
    render action: 'edit'
  end
end