diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 000000000..d3c4bdcaa --- /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 (1.9.6) + i18n (>= 0.7) + 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.0) + nio4r (2.4.0) + nokogiri (1.10.3) + 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.0.4) + 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.2) + 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/app/controllers/classrooms_controller.rb b/app/controllers/classrooms_controller.rb index 37b842336..d62bd3feb 100644 --- a/app/controllers/classrooms_controller.rb +++ b/app/controllers/classrooms_controller.rb @@ -1,7 +1,7 @@ class ClassroomsController < ApplicationController def show @classroom = Classroom.find(params[:id]) - @student = @classroom.oldest_student + # @student = @classroom.oldest_student # not needed end def index diff --git a/app/controllers/students_controller.rb b/app/controllers/students_controller.rb index 4cfeaba94..2c36b9cfa 100644 --- a/app/controllers/students_controller.rb +++ b/app/controllers/students_controller.rb @@ -21,10 +21,12 @@ def show end def index - @students = Student.all + # @students = Student.all #use custom search + @students = Student.search(params[:findme]) + end def student_params - params.require(:student).permit(:name, :birthday, :hometown) + params.require(:student).permit(:name, :birthday, :hometown, :findme) end end diff --git a/app/models/student.rb b/app/models/student.rb index 2e5955377..d19d34d29 100644 --- a/app/models/student.rb +++ b/app/models/student.rb @@ -13,4 +13,13 @@ class Student < ActiveRecord::Base has_many :classroom_students has_many :classrooms, through: :classroom_students + + def self.search(findme) + if findme == '' + self.all + else + # arr.select {|s| s.include? 'sa'} + self.all.select { |s| s.name.downcase.include?(findme) } + end + end end diff --git a/app/views/classrooms/_classroom.html.erb b/app/views/classrooms/_classroom.html.erb new file mode 100644 index 000000000..ac309ea0e --- /dev/null +++ b/app/views/classrooms/_classroom.html.erb @@ -0,0 +1 @@ +

<%= @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 b36238bb0..78c6c36f2 100644 --- a/app/views/classrooms/show.html.erb +++ b/app/views/classrooms/show.html.erb @@ -1,8 +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: -<%= 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..e95ad4902 100644 --- a/app/views/students/_form.html.erb +++ b/app/views/students/_form.html.erb @@ -1,4 +1,5 @@ -<%= 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..46fdfddb6 100644 --- a/app/views/students/_student.html.erb +++ b/app/views/students/_student.html.erb @@ -1,11 +1,12 @@ +

diff --git a/app/views/students/edit.html.erb b/app/views/students/edit.html.erb index 2d3436368..c5b2fb4b0 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} %> \ No newline at end of file diff --git a/app/views/students/index.html.erb b/app/views/students/index.html.erb new file mode 100644 index 000000000..c6a930282 --- /dev/null +++ b/app/views/students/index.html.erb @@ -0,0 +1,10 @@ +<%= form_tag students_path, method: :get do %> +

+ <%= text_field_tag :findme, params[:findme] %> + <%= 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/new.html.erb b/app/views/students/new.html.erb index 2d3436368..95d52e606 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} %> diff --git a/app/views/students/show.html.erb b/app/views/students/show.html.erb index aefa0b5c4..240959e58 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..423feb230 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,4 @@ Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html -end + resources :students +end \ No newline at end of file