Skip to content

Commit

Permalink
fix: views for students
Browse files Browse the repository at this point in the history
  • Loading branch information
csolg committed Jan 3, 2022
1 parent ede2fb2 commit cd72d4f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
4 changes: 4 additions & 0 deletions app/models/section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class Section < ApplicationRecord

before_save :set_weekdays

def to_s
"#{teacher.name}: #{subject.name} #{start_at}-#{end_at} #{room.name}"
end

def set_weekdays
case repeat_type
when 'everyday'
Expand Down
15 changes: 6 additions & 9 deletions app/views/students/_form.html.slim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
= form_with(model: student, local: true) do |form|
= simple_form_for(student) do |f|
- if student.errors.any?
#error_explanation
h2
Expand All @@ -8,11 +8,8 @@
- student.errors.full_messages.each do |message|
li
= message
.field
= form.label :first_name
= form.text_field :first_name
.field
= form.label :last_name
= form.text_field :last_name
.actions
= form.submit
= f.input :first_name
= f.input :last_name
= f.association :sections

= f.button :submit
22 changes: 15 additions & 7 deletions app/views/students/show.html.slim
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
p#notice
= notice
p
strong
dl.row
dt.col-sm-2
| First name:
= @student.first_name
p
strong
dd = @student.first_name

dt.col-sm-2
| Last name:
= @student.last_name
dd = @student.last_name

dt.col-sm-2
| Sections:
dd.col-sm-10
ul
- @student.sections.each do |section|
li
= link_to section.to_s, section_path(section)
= link_to 'Edit', edit_student_path(@student)
| |
| |
= link_to 'Back', students_path

0 comments on commit cd72d4f

Please sign in to comment.