Module: ResourceController::Actions

Defined in:
lib/resource_controller/actions.rb

Instance Method Summary collapse

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/resource_controller/actions.rb', line 18

def create
  build_object
  load_object
  before :create
  if object.save
    after :create
    set_flash :create
    response_for :create
  else
    after :create_fails
    set_flash :create_fails
    response_for :create_fails
  end
end

#destroyObject



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/resource_controller/actions.rb', line 60

def destroy
  load_object
  before :destroy
  if object.destroy
    after :destroy
    set_flash :destroy
    response_for :destroy
  else
    after :destroy_fails
    set_flash :destroy_fails
    response_for :destroy_fails
  end
end

#editObject



54
55
56
57
58
# File 'lib/resource_controller/actions.rb', line 54

def edit
  load_object
  before :edit
  response_for :edit
end

#indexObject



4
5
6
7
8
# File 'lib/resource_controller/actions.rb', line 4

def index
  load_collection
  before :index
  response_for :index
end

#newObject



47
48
49
50
51
52
# File 'lib/resource_controller/actions.rb', line 47

def new
  build_object
  load_object
  before :new_action
  response_for :new_action
end

#showObject



10
11
12
13
14
15
16
# File 'lib/resource_controller/actions.rb', line 10

def show
  load_object
  before :show
  response_for :show
rescue ActiveRecord::RecordNotFound
  response_for :show_fails
end

#updateObject



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/resource_controller/actions.rb', line 33

def update
  load_object
  before :update
  if object.update_attributes object_params
    after :update
    set_flash :update
    response_for :update
  else
    after :update_fails
    set_flash :update_fails
    response_for :update_fails
  end
end