Class: AbsencesController
Constant Summary
Localization::LOCALIZED_STRINGS
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, #record, #resolution_image, #t, #update_task, #with_detour
#l, load_localized_strings, #valid_language?
Instance Method Details
#create ⇒ Object
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
48
|
# File 'app/controllers/absences_controller.rb', line 23
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
64
65
66
67
|
# File 'app/controllers/absences_controller.rb', line 64
def destroy
Absence.find(params[:id]).destroy
redirect_to :action => 'list'
end
|
#edit ⇒ Object
50
51
52
|
# File 'app/controllers/absences_controller.rb', line 50
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
11
12
13
|
# File 'app/controllers/absences_controller.rb', line 11
def list
@absence_pages, @absences = paginate :absences, :per_page => 10
end
|
#new ⇒ Object
19
20
21
|
# File 'app/controllers/absences_controller.rb', line 19
def new
@absence = Absence.new
end
|
#show ⇒ Object
15
16
17
|
# File 'app/controllers/absences_controller.rb', line 15
def show
@absence = Absence.find(params[:id])
end
|
#update ⇒ Object
54
55
56
57
58
59
60
61
62
|
# File 'app/controllers/absences_controller.rb', line 54
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
|