Class: AbsencesController
Instance Method Summary
collapse
in_place_edit_for, #initialize
#back_or_link_to, #detour?, #detour_to, #display_notice, #h, #image_button_to, #image_detour_to, #image_link_to, #image_link_to_remote, #insert, #l, #record, #resolution_image, #t, #update_task, #with_detour
Instance Method Details
#create ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'app/controllers/absences_controller.rb', line 22
def create
@absence = Absence.find(:first, :conditions => {:on => params[:absence][:on], :user_id => current_user.id})
if @absence
if params[:absence][:reason] == ''
@absence.destroy
flash[:notice] = 'Absence was successfully destroyed.'
else
@absence.update_attributes(params[:absence])
flash[:notice] = 'Absence was successfully updated.'
end
back_or_redirect_to :action => 'list'
else
if params[:absence][:reason] == ''
back_or_redirect_to :action => 'list'
return
end
@absence = Absence.new(params[:absence])
@absence.user_id = current_user.id
if @absence.save
flash[:notice] = 'Absence was successfully created.'
back_or_redirect_to :action => 'list'
else
render :action => 'new'
end
end
end
|
#destroy ⇒ Object
63
64
65
66
|
# File 'app/controllers/absences_controller.rb', line 63
def destroy
Absence.find(params[:id]).destroy
redirect_to :action => 'list'
end
|
#edit ⇒ Object
49
50
51
|
# File 'app/controllers/absences_controller.rb', line 49
def edit
@absence = Absence.find(params[:id])
end
|
#index ⇒ Object
2
3
4
5
|
# File 'app/controllers/absences_controller.rb', line 2
def index
list
render :action => 'list'
end
|
#list ⇒ Object
10
11
12
|
# File 'app/controllers/absences_controller.rb', line 10
def list
@absences = Absence.paginate :per_page => 10, :page => params[:page]
end
|
#new ⇒ Object
18
19
20
|
# File 'app/controllers/absences_controller.rb', line 18
def new
@absence = Absence.new
end
|
#show ⇒ Object
14
15
16
|
# File 'app/controllers/absences_controller.rb', line 14
def show
@absence = Absence.find(params[:id])
end
|
#update ⇒ Object
53
54
55
56
57
58
59
60
61
|
# File 'app/controllers/absences_controller.rb', line 53
def update
@absence = Absence.find(params[:id])
if @absence.update_attributes(params[:absence])
flash[:notice] = 'Absence was successfully updated.'
redirect_to :action => 'show', :id => @absence
else
render :action => 'edit'
end
end
|