Skip to content

Commit dc5803f

Browse files
committed
Use emails instead of usernames when adding and listing organization's teachers
1 parent 41989ef commit dc5803f

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

app/controllers/teachers_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ def index
1515
def create
1616
authorize! :teach, @organization
1717

18-
user = User.find_by(login: teacher_params[:username])
18+
user = User.find_by(email: teacher_params[:email])
1919
@teachership = Teachership.new(user: user, organization: @organization)
2020

2121
if @teachership.save
22-
redirect_to organization_teachers_path, notice: "Teacher #{user.login} added to organization"
22+
redirect_to organization_teachers_path, notice: "Teacher #{user.email} added to organization"
2323
else
2424
@teachers = @organization.teachers
2525
render :index

app/views/teachers/_form.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<%= render 'shared/error_messages', target: @teachership %>
55

66
<div class="form-group">
7-
<%= label nil, :username %>
8-
<%= text_field_tag :username, nil, class: 'form-control' %>
7+
<%= label nil, :email %>
8+
<%= text_field_tag :email, nil, class: 'form-control' %>
99
</div>
1010
<div class="actions">
1111
<%= submit_tag 'Add a new teacher', class: 'btn btn-primary' %>

app/views/teachers/index.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<tbody>
2323
<% @teachers.each do |teacher| %>
2424
<tr>
25-
<td><%= teacher.username %></td>
25+
<td><%= teacher.email %></td>
2626
<td><%= link_to 'Remove', organization_teacher_path(@organization, teacher.teachership(@organization)), method: :delete, class: "btn btn-sm btn-danger", data: { confirm: 'Are you sure?' } %></td>
2727
</tr>
2828
<% end %>

0 commit comments

Comments
 (0)