Class: FinePrint::ContractsController

Inherits:
ApplicationController show all
Includes:
ApplicationHelper
Defined in:
app/controllers/fine_print/contracts_controller.rb

Instance Method Summary collapse

Methods included from ApplicationHelper

#merge_errors_for

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/fine_print/contracts_controller.rb', line 20

def create
  @contract = Contract.new
  @contract.name = params[:contract][:name]
  @contract.title = params[:contract][:title]
  @contract.content = params[:contract][:content]
  
  if @contract.save
    redirect_to @contract, :notice => 'Contract was successfully created.'
  else
    render :action => 'new'
  end
end

#destroyObject



45
46
47
48
49
50
51
# File 'app/controllers/fine_print/contracts_controller.rb', line 45

def destroy
  if @contract.destroy
    redirect_to contracts_path, :notice => 'Contract was successfully deleted.'
  else
    redirect_to contracts_path, :alert => merge_errors_for(@contract)
  end
end

#editObject



17
18
# File 'app/controllers/fine_print/contracts_controller.rb', line 17

def edit
end

#indexObject



6
7
8
# File 'app/controllers/fine_print/contracts_controller.rb', line 6

def index
  @contracts = Contract.all
end

#newObject



13
14
15
# File 'app/controllers/fine_print/contracts_controller.rb', line 13

def new
  @contract = Contract.new
end

#new_versionObject



69
70
71
# File 'app/controllers/fine_print/contracts_controller.rb', line 69

def new_version
  @contract = @contract.draft_copy
end

#publishObject



53
54
55
56
57
58
59
# File 'app/controllers/fine_print/contracts_controller.rb', line 53

def publish
  if @contract.publish
    redirect_to contracts_path, :notice => 'Contract was successfully published.'
  else
    redirect_to contracts_path, :alert => merge_errors_for(@contract)
  end
end

#showObject



10
11
# File 'app/controllers/fine_print/contracts_controller.rb', line 10

def show
end

#unpublishObject



61
62
63
64
65
66
67
# File 'app/controllers/fine_print/contracts_controller.rb', line 61

def unpublish
  if @contract.unpublish
    redirect_to contracts_path, :notice => 'Contract was successfully unpublished.'
  else
    redirect_to contracts_path, :alert => merge_errors_for(@contract)
  end
end

#updateObject



33
34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/fine_print/contracts_controller.rb', line 33

def update
  @contract.name = params[:contract][:name]
  @contract.title = params[:contract][:title]
  @contract.content = params[:contract][:content]

  if @contract.save
    redirect_to @contract, :notice => 'Contract was successfully updated.'
  else
    render :action => 'edit'
  end
end