Class: Gaku::EnrollmentsController
Instance Method Summary
collapse
#resolve_layout
Instance Method Details
#create ⇒ Object
49
50
51
52
53
54
|
# File 'app/controllers/gaku/enrollments_controller.rb', line 49
def create
@enrollment = @enrollmentable.enrollments.build(enrollment_params)
@enrollment.save
set_count
respond_with @enrollment
end
|
#create_from_selection ⇒ 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/gaku/enrollments_controller.rb', line 22
def create_from_selection
if params[:selected_students].blank?
missing_selected_students
else
@enrollments, students = [], {}
students[:enrolled], students[:not_found], students[:failed] = [], [], []
params[:selected_students].each do |student_id|
student = Student.where(id: student_id).first
if student
enrollment = @enrollmentable.enrollments.build(student_id: student_id)
if enrollment.save
@enrollments << enrollment
students[:enrolled] << student.decorate.full_name
else
students[:failed] << enrollment
end
else
students[:not_found] << student_id
end
end
set_flash_messages(students)
set_count
end
end
|
#destroy ⇒ Object
56
57
58
59
60
|
# File 'app/controllers/gaku/enrollments_controller.rb', line 56
def destroy
@enrollment.destroy
set_count
respond_with @enrollment
end
|
#index ⇒ Object
10
11
|
# File 'app/controllers/gaku/enrollments_controller.rb', line 10
def index
end
|
#new ⇒ Object
18
19
20
|
# File 'app/controllers/gaku/enrollments_controller.rb', line 18
def new
@enrollment = @enrollmentable.enrollments.new
end
|
#student_selection ⇒ Object
13
14
15
16
|
# File 'app/controllers/gaku/enrollments_controller.rb', line 13
def student_selection
@enrollment = @enrollmentable.enrollments.new
@student_selection = Gaku::StudentSelection.new(current_user).all
end
|