From 792dab94329047552b8dc213e08a654fc8196b16 Mon Sep 17 00:00:00 2001
From: Paul Fell
Date: Mon, 12 Aug 2019 16:13:24 -0400
Subject: [PATCH 1/5] Done.
---
Gemfile.lock | 197 +++++++++++++++++++++++
db/schema.rb | 1 -
db/seeds.rb | 2 +-
spec/models/student_spec.rb | 2 +-
spec/views/classroom_show_spec.rb | 4 +-
spec/views/student_index_spec.rb | 2 +-
spec/views/student_new_edit_form_spec.rb | 6 +-
spec/views/student_show_spec.rb | 2 +-
8 files changed, 206 insertions(+), 10 deletions(-)
create mode 100644 Gemfile.lock
diff --git a/Gemfile.lock b/Gemfile.lock
new file mode 100644
index 000000000..08ccdcf9e
--- /dev/null
+++ b/Gemfile.lock
@@ -0,0 +1,197 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ actioncable (5.0.7.2)
+ actionpack (= 5.0.7.2)
+ nio4r (>= 1.2, < 3.0)
+ websocket-driver (~> 0.6.1)
+ actionmailer (5.0.7.2)
+ actionpack (= 5.0.7.2)
+ actionview (= 5.0.7.2)
+ activejob (= 5.0.7.2)
+ mail (~> 2.5, >= 2.5.4)
+ rails-dom-testing (~> 2.0)
+ actionpack (5.0.7.2)
+ actionview (= 5.0.7.2)
+ activesupport (= 5.0.7.2)
+ rack (~> 2.0)
+ rack-test (~> 0.6.3)
+ rails-dom-testing (~> 2.0)
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
+ actionview (5.0.7.2)
+ activesupport (= 5.0.7.2)
+ builder (~> 3.1)
+ erubis (~> 2.7.0)
+ rails-dom-testing (~> 2.0)
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
+ activejob (5.0.7.2)
+ activesupport (= 5.0.7.2)
+ globalid (>= 0.3.6)
+ activemodel (5.0.7.2)
+ activesupport (= 5.0.7.2)
+ activerecord (5.0.7.2)
+ activemodel (= 5.0.7.2)
+ activesupport (= 5.0.7.2)
+ arel (~> 7.0)
+ activesupport (5.0.7.2)
+ concurrent-ruby (~> 1.0, >= 1.0.2)
+ i18n (>= 0.7, < 2)
+ minitest (~> 5.1)
+ tzinfo (~> 1.1)
+ annotate (2.7.5)
+ activerecord (>= 3.2, < 7.0)
+ rake (>= 10.4, < 13.0)
+ arel (7.1.4)
+ bootsnap (1.4.4)
+ msgpack (~> 1.0)
+ builder (3.2.3)
+ coffee-rails (4.1.1)
+ coffee-script (>= 2.2.0)
+ railties (>= 4.0.0, < 5.1.x)
+ coffee-script (2.4.1)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.12.2)
+ concurrent-ruby (1.1.5)
+ crass (1.0.4)
+ diff-lcs (1.3)
+ erubis (2.7.0)
+ execjs (2.7.0)
+ faker (2.1.2)
+ i18n (>= 0.8)
+ ffi (1.11.1)
+ globalid (0.4.2)
+ activesupport (>= 4.2.0)
+ i18n (1.6.0)
+ concurrent-ruby (~> 1.0)
+ jbuilder (2.9.1)
+ activesupport (>= 4.2.0)
+ jquery-rails (4.3.5)
+ rails-dom-testing (>= 1, < 3)
+ railties (>= 4.2.0)
+ thor (>= 0.14, < 2.0)
+ json (1.8.6)
+ loofah (2.2.3)
+ crass (~> 1.0.2)
+ nokogiri (>= 1.5.9)
+ mail (2.7.1)
+ mini_mime (>= 0.1.1)
+ method_source (0.9.2)
+ mini_mime (1.0.2)
+ mini_portile2 (2.4.0)
+ minitest (5.11.3)
+ msgpack (1.3.1)
+ nio4r (2.4.0)
+ nokogiri (1.10.4)
+ mini_portile2 (~> 2.4.0)
+ rack (2.0.7)
+ rack-test (0.6.3)
+ rack (>= 1.0)
+ rails (5.0.7.2)
+ actioncable (= 5.0.7.2)
+ actionmailer (= 5.0.7.2)
+ actionpack (= 5.0.7.2)
+ actionview (= 5.0.7.2)
+ activejob (= 5.0.7.2)
+ activemodel (= 5.0.7.2)
+ activerecord (= 5.0.7.2)
+ activesupport (= 5.0.7.2)
+ bundler (>= 1.3.0)
+ railties (= 5.0.7.2)
+ sprockets-rails (>= 2.0.0)
+ rails-controller-testing (1.0.4)
+ actionpack (>= 5.0.1.x)
+ actionview (>= 5.0.1.x)
+ activesupport (>= 5.0.1.x)
+ rails-dom-testing (2.0.3)
+ activesupport (>= 4.2.0)
+ nokogiri (>= 1.6)
+ rails-html-sanitizer (1.2.0)
+ loofah (~> 2.2, >= 2.2.2)
+ railties (5.0.7.2)
+ actionpack (= 5.0.7.2)
+ activesupport (= 5.0.7.2)
+ method_source
+ rake (>= 0.8.7)
+ thor (>= 0.18.1, < 2.0)
+ rake (12.3.3)
+ rb-fsevent (0.10.3)
+ rb-inotify (0.10.0)
+ ffi (~> 1.0)
+ rdoc (4.3.0)
+ rspec-core (3.8.2)
+ rspec-support (~> 3.8.0)
+ rspec-expectations (3.8.4)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.8.0)
+ rspec-mocks (3.8.1)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.8.0)
+ rspec-rails (4.0.0.beta2)
+ actionpack (>= 4.2)
+ activesupport (>= 4.2)
+ railties (>= 4.2)
+ rspec-core (~> 3.8)
+ rspec-expectations (~> 3.8)
+ rspec-mocks (~> 3.8)
+ rspec-support (~> 3.8)
+ rspec-support (3.8.2)
+ sass (3.7.4)
+ sass-listen (~> 4.0.0)
+ sass-listen (4.0.0)
+ rb-fsevent (~> 0.9, >= 0.9.4)
+ rb-inotify (~> 0.9, >= 0.9.7)
+ sass-rails (5.0.7)
+ railties (>= 4.0.0, < 6)
+ sass (~> 3.1)
+ sprockets (>= 2.8, < 4.0)
+ sprockets-rails (>= 2.0, < 4.0)
+ tilt (>= 1.1, < 3)
+ sdoc (0.4.2)
+ json (~> 1.7, >= 1.7.7)
+ rdoc (~> 4.0)
+ spring (2.1.0)
+ sprockets (3.7.2)
+ concurrent-ruby (~> 1.0)
+ rack (> 1, < 3)
+ sprockets-rails (3.2.1)
+ actionpack (>= 4.0)
+ activesupport (>= 4.0)
+ sprockets (>= 3.0.0)
+ sqlite3 (1.3.13)
+ thor (0.20.3)
+ thread_safe (0.3.6)
+ tilt (2.0.9)
+ turbolinks (5.2.0)
+ turbolinks-source (~> 5.2)
+ turbolinks-source (5.2.0)
+ tzinfo (1.2.5)
+ thread_safe (~> 0.1)
+ uglifier (4.1.20)
+ execjs (>= 0.3.0, < 3)
+ websocket-driver (0.6.5)
+ websocket-extensions (>= 0.1.0)
+ websocket-extensions (0.1.4)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ annotate
+ bootsnap
+ coffee-rails (~> 4.1.0)
+ faker
+ jbuilder (~> 2.0)
+ jquery-rails
+ rails
+ rails-controller-testing
+ rspec-rails (>= 2.0.0.beta)
+ sass-rails (~> 5.0)
+ sdoc (~> 0.4.0)
+ spring
+ sqlite3 (~> 1.3.6)
+ turbolinks
+ uglifier (>= 1.3.0)
+
+BUNDLED WITH
+ 2.0.1
diff --git a/db/schema.rb b/db/schema.rb
index a8f1d5d04..682993151 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -1,4 +1,3 @@
-# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
diff --git a/db/seeds.rb b/db/seeds.rb
index 71b9e64ad..1d4d0943c 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -6,7 +6,7 @@
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
80.times do
- Student.create(name: Faker::Name.name, hometown: Faker::Address.city, birthday: Faker::Date.between(25.years.ago, 18.years.ago))
+ Student.create(name: Faker::Name.name, hometown: Faker::Address.city, birthday: Faker::Date.between(from: 25.years.ago, to: 18.years.ago))
end
Classroom.create(course_name: 'Math', semester: "Spring #{Time.now.year}")
Classroom.create(course_name: 'English', semester: "Fall #{Time.now.year}")
diff --git a/spec/models/student_spec.rb b/spec/models/student_spec.rb
index 2a774c192..c7b1470ba 100644
--- a/spec/models/student_spec.rb
+++ b/spec/models/student_spec.rb
@@ -6,7 +6,7 @@
before do
student_names.each do |name|
- Student.create(name: name, hometown: Faker::Address.city, birthday: Faker::Date.between(25.years.ago, 18.years.ago))
+ Student.create(name: name, hometown: Faker::Address.city, birthday: Faker::Date.between(from: 25.years.ago, to: 18.years.ago))
end
end
diff --git a/spec/views/classroom_show_spec.rb b/spec/views/classroom_show_spec.rb
index 30a12d0be..2d2d5f31d 100644
--- a/spec/views/classroom_show_spec.rb
+++ b/spec/views/classroom_show_spec.rb
@@ -2,11 +2,11 @@
RSpec.describe 'classroom_show_view' do
let(:classroom) { Classroom.create(course_name: 'Math', semester: "Spring #{Time.now.year}") }
- let(:student) { Student.create(name: 'Bobby', hometown: Faker::Address.city, birthday: Faker::Date.between(25.years.ago, 18.years.ago)) }
+ let(:student) { Student.create(name: 'Bobby', hometown: Faker::Address.city, birthday: Faker::Date.between(from: 25.years.ago, to: 18.years.ago)) }
before do
5.times do
- Student.create(name: Faker::Name.name, hometown: Faker::Address.city, birthday: Faker::Date.between(25.years.ago, 18.years.ago))
+ Student.create(name: Faker::Name.name, hometown: Faker::Address.city, birthday: Faker::Date.between(from: 25.years.ago, to: 18.years.ago))
end
Student.all.each do |student|
ClassroomStudent.create(student: student, classroom: classroom)
diff --git a/spec/views/student_index_spec.rb b/spec/views/student_index_spec.rb
index 7f60620e4..669d4ab50 100644
--- a/spec/views/student_index_spec.rb
+++ b/spec/views/student_index_spec.rb
@@ -7,7 +7,7 @@
before do
student_names.each do |name|
- Student.create(name: name, hometown: Faker::Address.city, birthday: Faker::Date.between(25.years.ago, 18.years.ago))
+ Student.create(name: name, hometown: Faker::Address.city, birthday: Faker::Date.between(from: 25.years.ago, to: 18.years.ago))
end
end
diff --git a/spec/views/student_new_edit_form_spec.rb b/spec/views/student_new_edit_form_spec.rb
index 587c750e5..9fb275a90 100644
--- a/spec/views/student_new_edit_form_spec.rb
+++ b/spec/views/student_new_edit_form_spec.rb
@@ -32,7 +32,7 @@
describe 'edit form' do
it "renders edit student form from the edit.html file" do
view.lookup_context.prefixes = %w[students]
- student = Student.create(name: 'Bobby', hometown: Faker::Address.city, birthday: Faker::Date.between(25.years.ago, 18.years.ago))
+ student = Student.create(name: 'Bobby', hometown: Faker::Address.city, birthday: Faker::Date.between(from: 25.years.ago, to: 18.years.ago))
assign(:student, student)
render :template => "students/edit.html.erb"
expect(rendered).to match /Update Student/
@@ -40,7 +40,7 @@
it "directly renders the form in a students/form partial with the form object passed through as a local variable" do
view.lookup_context.prefixes = %w[students]
- student = Student.create(name: 'Bobby', hometown: Faker::Address.city, birthday: Faker::Date.between(25.years.ago, 18.years.ago))
+ student = Student.create(name: 'Bobby', hometown: Faker::Address.city, birthday: Faker::Date.between(from: 25.years.ago, to: 18.years.ago))
assign(:student, student)
render :template => "students/new.html.erb"
@@ -50,7 +50,7 @@
it "directly renders the form in a students/form partial with the form object passed through as a local variable" do
view.lookup_context.prefixes = %w[students]
- student = Student.create(name: 'Bobby', hometown: Faker::Address.city, birthday: Faker::Date.between(25.years.ago, 18.years.ago))
+ student = Student.create(name: 'Bobby', hometown: Faker::Address.city, birthday: Faker::Date.between(from: 25.years.ago, to: 18.years.ago))
assign(:student, student)
render :template => "students/edit.html.erb"
diff --git a/spec/views/student_show_spec.rb b/spec/views/student_show_spec.rb
index 07b04acfd..3ed137cb9 100644
--- a/spec/views/student_show_spec.rb
+++ b/spec/views/student_show_spec.rb
@@ -1,7 +1,7 @@
require "rails_helper"
RSpec.describe "show_view" do
- let(:student){ Student.create(name: 'Bobby', hometown: Faker::Address.city, birthday: Faker::Date.between(25.years.ago, 18.years.ago)) }
+ let(:student){ Student.create(name: 'Bobby', hometown: Faker::Address.city, birthday: Faker::Date.between(from: 25.years.ago, to: 18.years.ago)) }
it "renders student information from the classroom show view" do
view.lookup_context.prefixes = %w[students]
From c2bd7d1dd2f590cd5af2e17e7e506cca2763cc25 Mon Sep 17 00:00:00 2001
From: Paul Fell
Date: Mon, 12 Aug 2019 16:33:39 -0400
Subject: [PATCH 2/5] Done.
---
app/views/classrooms/_classroom.html.erb | 0
app/views/classrooms/show.html.erb | 4 +++-
app/views/students/_form.html.erb | 2 +-
app/views/students/_student.html.erb | 6 +++---
app/views/students/edit.html.erb | 2 +-
app/views/students/new.html.erb | 2 +-
6 files changed, 9 insertions(+), 7 deletions(-)
create mode 100644 app/views/classrooms/_classroom.html.erb
diff --git a/app/views/classrooms/_classroom.html.erb b/app/views/classrooms/_classroom.html.erb
new file mode 100644
index 000000000..e69de29bb
diff --git a/app/views/classrooms/show.html.erb b/app/views/classrooms/show.html.erb
index b36238bb0..1486fca2f 100644
--- a/app/views/classrooms/show.html.erb
+++ b/app/views/classrooms/show.html.erb
@@ -5,4 +5,6 @@ Classroom Info
We now want to call out the oldest student in the class:
-<%= render 'students/student' %>
+<% classroom.students.each do |student| %>
+<%= render partial: 'students/student', locals: {student: @student} %>
+<% end %>
\ No newline at end of file
diff --git a/app/views/students/_form.html.erb b/app/views/students/_form.html.erb
index 89d2115e2..cdabc6442 100644
--- a/app/views/students/_form.html.erb
+++ b/app/views/students/_form.html.erb
@@ -1,4 +1,4 @@
-<%= form_for @student do |f|%>
+<%= form_for (student) do |f|%>
<%= f.label :name %>
<%= f.text_field :name %>
diff --git a/app/views/students/_student.html.erb b/app/views/students/_student.html.erb
index 2998c1197..2e0e23e15 100644
--- a/app/views/students/_student.html.erb
+++ b/app/views/students/_student.html.erb
@@ -1,11 +1,11 @@
-
- Name: <%= @student.name %>
+ Name: <%= student.name %>
-
- Birthday: <%= @student.birthday.strftime("%m/%d/%Y") %>
+ Birthday: <%= student.birthday.strftime("%m/%d/%Y") %>
-
- Hometown: <%= @student.hometown.capitalize %>
+ Hometown: <%= student.hometown.capitalize %>
diff --git a/app/views/students/edit.html.erb b/app/views/students/edit.html.erb
index 2d3436368..bc2eefede 100644
--- a/app/views/students/edit.html.erb
+++ b/app/views/students/edit.html.erb
@@ -1 +1 @@
-<%= render 'form' %>
+<%= render partial: 'form', locals: {student: @student} %>
diff --git a/app/views/students/new.html.erb b/app/views/students/new.html.erb
index 2d3436368..bc2eefede 100644
--- a/app/views/students/new.html.erb
+++ b/app/views/students/new.html.erb
@@ -1 +1 @@
-<%= render 'form' %>
+<%= render partial: 'form', locals: {student: @student} %>
From 1b0e2511c7d3e5f5cc47308359657492b8d94d71 Mon Sep 17 00:00:00 2001
From: Paul Fell
Date: Mon, 12 Aug 2019 19:18:45 -0400
Subject: [PATCH 3/5] Done.
---
Gemfile | 2 +-
Gemfile.lock | 5 +++++
app/controllers/classrooms_controller.rb | 7 +++----
app/controllers/students_controller.rb | 4 +++-
app/models/classroom.rb | 8 +++++---
app/models/student.rb | 14 ++++++++++++++
app/views/classrooms/_classroom.html.erb | 4 ++++
app/views/classrooms/show.html.erb | 8 ++------
app/views/students/_form.html.erb | 2 +-
app/views/students/index.html.erb | 10 ++++++++++
app/views/students/show.html.erb | 2 +-
config/routes.rb | 2 ++
spec/views/classroom_show_spec.rb | 2 +-
13 files changed, 52 insertions(+), 18 deletions(-)
create mode 100644 app/views/students/index.html.erb
diff --git a/Gemfile b/Gemfile
index 6bc46c3a3..59a9945f5 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,6 +1,6 @@
source 'https://rubygems.org'
-
+gem 'pry'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails'
# Use sqlite3 as the database for Active Record
diff --git a/Gemfile.lock b/Gemfile.lock
index 08ccdcf9e..76c21413c 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -45,6 +45,7 @@ GEM
bootsnap (1.4.4)
msgpack (~> 1.0)
builder (3.2.3)
+ coderay (1.1.2)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x)
@@ -84,6 +85,9 @@ GEM
nio4r (2.4.0)
nokogiri (1.10.4)
mini_portile2 (~> 2.4.0)
+ pry (0.12.2)
+ coderay (~> 1.1.0)
+ method_source (~> 0.9.0)
rack (2.0.7)
rack-test (0.6.3)
rack (>= 1.0)
@@ -183,6 +187,7 @@ DEPENDENCIES
faker
jbuilder (~> 2.0)
jquery-rails
+ pry
rails
rails-controller-testing
rspec-rails (>= 2.0.0.beta)
diff --git a/app/controllers/classrooms_controller.rb b/app/controllers/classrooms_controller.rb
index 37b842336..e922eb832 100644
--- a/app/controllers/classrooms_controller.rb
+++ b/app/controllers/classrooms_controller.rb
@@ -1,10 +1,9 @@
class ClassroomsController < ApplicationController
def show
@classroom = Classroom.find(params[:id])
- @student = @classroom.oldest_student
end
- def index
- @classrooms = Classroom.all
- end
+ # def index
+ # @classrooms = Classroom.all
+ # end
end
diff --git a/app/controllers/students_controller.rb b/app/controllers/students_controller.rb
index 4cfeaba94..6ac949d2e 100644
--- a/app/controllers/students_controller.rb
+++ b/app/controllers/students_controller.rb
@@ -21,7 +21,9 @@ def show
end
def index
- @students = Student.all
+ binding.pry
+ @students = Student.search(params[:query])
+ render 'index'
end
def student_params
diff --git a/app/models/classroom.rb b/app/models/classroom.rb
index 96b78004a..9730670a0 100644
--- a/app/models/classroom.rb
+++ b/app/models/classroom.rb
@@ -13,7 +13,9 @@ class Classroom < ActiveRecord::Base
has_many :classroom_students
has_many :students, through: :classroom_students
- def oldest_student
- students.where("birthday is not null").order("birthday asc").first
+ # def oldest_student
+ # students.where("birthday is not null").order("birthday asc").first
+ # end
+
+
end
-end
diff --git a/app/models/student.rb b/app/models/student.rb
index 2e5955377..ca921d235 100644
--- a/app/models/student.rb
+++ b/app/models/student.rb
@@ -13,4 +13,18 @@
class Student < ActiveRecord::Base
has_many :classroom_students
has_many :classrooms, through: :classroom_students
+
+
+ def self.search(query)
+ # binding.pry
+ if query.present?
+ where (['name LIKE ?', "%#{query}%"])
+ else
+ self.all
+ end
+ end
+
+
end
+
+
diff --git a/app/views/classrooms/_classroom.html.erb b/app/views/classrooms/_classroom.html.erb
index e69de29bb..c62000fb1 100644
--- a/app/views/classrooms/_classroom.html.erb
+++ b/app/views/classrooms/_classroom.html.erb
@@ -0,0 +1,4 @@
+
+ <%= @classroom.course_name %>
+ <%= @classroom.semester %>
+
\ No newline at end of file
diff --git a/app/views/classrooms/show.html.erb b/app/views/classrooms/show.html.erb
index 1486fca2f..8e68c6e64 100644
--- a/app/views/classrooms/show.html.erb
+++ b/app/views/classrooms/show.html.erb
@@ -1,10 +1,6 @@
Classroom Info
-
-<%= @classroom.course_name %>
-<%= @classroom.semester %>
-
+<%= render partial: 'classroom', locals: {classroom: @classroom} %>
-We now want to call out the oldest student in the class:
-<% classroom.students.each do |student| %>
+<% @classroom.students.each do |student| %>
<%= render partial: 'students/student', locals: {student: @student} %>
<% end %>
\ No newline at end of file
diff --git a/app/views/students/_form.html.erb b/app/views/students/_form.html.erb
index cdabc6442..aaad29956 100644
--- a/app/views/students/_form.html.erb
+++ b/app/views/students/_form.html.erb
@@ -1,4 +1,4 @@
-<%= form_for (student) do |f|%>
+<%= form_for(student) do |f|%>
<%= f.label :name %>
<%= f.text_field :name %>
diff --git a/app/views/students/index.html.erb b/app/views/students/index.html.erb
new file mode 100644
index 000000000..0fb65a92e
--- /dev/null
+++ b/app/views/students/index.html.erb
@@ -0,0 +1,10 @@
+<%= form_tag students_path, method: :get do %>
+
+ <%= text_field_tag :query, params[:query] %>
+ <%= submit_tag "Search", name: nil %>
+
+<% end %>
+
+<% @students.each do |student| %>
+ <%= render partial: 'student', locals: {student: student} %>
+<% end %>
\ No newline at end of file
diff --git a/app/views/students/show.html.erb b/app/views/students/show.html.erb
index aefa0b5c4..e719b592a 100644
--- a/app/views/students/show.html.erb
+++ b/app/views/students/show.html.erb
@@ -1,3 +1,3 @@
Student Info
-<%= render 'student' %>
+<%= render partial: 'student' , locals: {student: student} %>
diff --git a/config/routes.rb b/config/routes.rb
index 787824f88..293e75e5f 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,3 +1,5 @@
Rails.application.routes.draw do
+ resources :classrooms
+ resources :students
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
diff --git a/spec/views/classroom_show_spec.rb b/spec/views/classroom_show_spec.rb
index 2d2d5f31d..0710e1f46 100644
--- a/spec/views/classroom_show_spec.rb
+++ b/spec/views/classroom_show_spec.rb
@@ -15,7 +15,7 @@
it 'renders classroom information on the show view' do
view.lookup_context.prefixes = %w[students classrooms]
- student = Student.create(name: 'Bobby', hometown: Faker::Address.city, birthday: Faker::Date.between(25.years.ago, 18.years.ago))
+ student = Student.create(name: 'Bobby', hometown: Faker::Address.city, birthday: Faker::Date.between(from: 25.years.ago, to: 18.years.ago))
assign(:classroom, classroom)
render template: 'classrooms/show.html.erb'
expect(rendered).to match /Math/
From c8022b664ba7d2238d2501cf621bb1718d5e3eb8 Mon Sep 17 00:00:00 2001
From: Paul Fell
Date: Mon, 12 Aug 2019 19:54:36 -0400
Subject: [PATCH 4/5] Done.
---
app/controllers/classrooms_controller.rb | 6 +++---
app/views/classrooms/_classroom.html.erb | 4 ++--
app/views/classrooms/show.html.erb | 2 +-
app/views/students/show.html.erb | 2 +-
4 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/app/controllers/classrooms_controller.rb b/app/controllers/classrooms_controller.rb
index e922eb832..dc4d164c1 100644
--- a/app/controllers/classrooms_controller.rb
+++ b/app/controllers/classrooms_controller.rb
@@ -3,7 +3,7 @@ def show
@classroom = Classroom.find(params[:id])
end
- # def index
- # @classrooms = Classroom.all
- # end
+ def index
+ @classrooms = Classroom.all
+ end
end
diff --git a/app/views/classrooms/_classroom.html.erb b/app/views/classrooms/_classroom.html.erb
index c62000fb1..555ba40ef 100644
--- a/app/views/classrooms/_classroom.html.erb
+++ b/app/views/classrooms/_classroom.html.erb
@@ -1,4 +1,4 @@
- <%= @classroom.course_name %>
- <%= @classroom.semester %>
+ <%= classroom.course_name %>
+ <%= classroom.semester %>
\ No newline at end of file
diff --git a/app/views/classrooms/show.html.erb b/app/views/classrooms/show.html.erb
index 8e68c6e64..0e29fdeed 100644
--- a/app/views/classrooms/show.html.erb
+++ b/app/views/classrooms/show.html.erb
@@ -2,5 +2,5 @@ Classroom Info
<%= render partial: 'classroom', locals: {classroom: @classroom} %>
<% @classroom.students.each do |student| %>
-<%= render partial: 'students/student', locals: {student: @student} %>
+<%= render partial: 'students/student', locals: {student: student} %>
<% end %>
\ No newline at end of file
diff --git a/app/views/students/show.html.erb b/app/views/students/show.html.erb
index e719b592a..9a1548823 100644
--- a/app/views/students/show.html.erb
+++ b/app/views/students/show.html.erb
@@ -1,3 +1,3 @@
Student Info
-<%= render partial: 'student' , locals: {student: student} %>
+<%= render partial: 'student' , locals: {student: @student} %>
From db189b3acf92aad2e81d603a8aff7692349a1e4d Mon Sep 17 00:00:00 2001
From: Paul Fell
Date: Mon, 12 Aug 2019 19:57:54 -0400
Subject: [PATCH 5/5] Done.
---
app/views/classrooms/index.html.erb | 0
app/views/classrooms/show.html.erb | 2 +-
2 files changed, 1 insertion(+), 1 deletion(-)
delete mode 100644 app/views/classrooms/index.html.erb
diff --git a/app/views/classrooms/index.html.erb b/app/views/classrooms/index.html.erb
deleted file mode 100644
index e69de29bb..000000000
diff --git a/app/views/classrooms/show.html.erb b/app/views/classrooms/show.html.erb
index 0e29fdeed..e12447102 100644
--- a/app/views/classrooms/show.html.erb
+++ b/app/views/classrooms/show.html.erb
@@ -2,5 +2,5 @@ Classroom Info
<%= render partial: 'classroom', locals: {classroom: @classroom} %>
<% @classroom.students.each do |student| %>
-<%= render partial: 'students/student', locals: {student: student} %>
+ <%= render partial: 'students/student', locals: {student: student} %>
<% end %>
\ No newline at end of file