Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Done #1081

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Done #1081

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

gem 'pry'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

Expand Down
202 changes: 202 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
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 (3.1.1)
activerecord (>= 3.2, < 7.0)
rake (>= 10.4, < 14.0)
arel (7.1.4)
bootsnap (1.7.5)
msgpack (~> 1.0)
builder (3.2.4)
coderay (1.1.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.9)
crass (1.0.6)
diff-lcs (1.4.4)
erubis (2.7.0)
execjs (2.8.1)
faker (2.4.0)
i18n (~> 1.6.0)
ffi (1.15.3)
globalid (0.4.2)
activesupport (>= 4.2.0)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
jbuilder (2.11.2)
activesupport (>= 5.0.0)
jquery-rails (4.4.0)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.6)
loofah (2.10.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
method_source (1.0.0)
mini_mime (1.1.0)
minitest (5.14.4)
msgpack (1.4.2)
nio4r (2.5.7)
nokogiri (1.11.7-x86_64-darwin)
racc (~> 1.4)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
racc (1.5.2)
rack (2.2.3)
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.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
activesupport (>= 5.0.1.rc1)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
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 (13.0.3)
rb-fsevent (0.11.0)
rb-inotify (0.10.1)
ffi (~> 1.0)
rdoc (4.3.0)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-rails (4.1.2)
actionpack (>= 4.2)
activesupport (>= 4.2)
railties (>= 4.2)
rspec-core (~> 3.10)
rspec-expectations (~> 3.10)
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.10.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.1)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.2)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
thor (1.1.0)
thread_safe (0.3.6)
tilt (2.0.10)
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
tzinfo (1.2.9)
thread_safe (~> 0.1)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)

PLATFORMS
x86_64-darwin-19

DEPENDENCIES
annotate
bootsnap
coffee-rails (~> 4.1.0)
faker (~> 2.4.0)
jbuilder (~> 2.0)
jquery-rails
pry
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.2.15
7 changes: 6 additions & 1 deletion app/controllers/students_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ def show
end

def index
@students = Student.all
if params[:query]
@students = Student.all.filter{|s| s.name == params[:query]}
else
@students = Student.all
end

end

def student_params
Expand Down
8 changes: 8 additions & 0 deletions app/models/student.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@
class Student < ActiveRecord::Base
has_many :classroom_students
has_many :classrooms, through: :classroom_students

def self.search(term)
if term == ""
return Student.all
else
return Student.all.filter{|s| s.name.downcase.include?(term.downcase) }
end
end
end
5 changes: 5 additions & 0 deletions app/views/classrooms/_classroom.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Classroom Info
<p>
<%= classroom.course_name %>
<%= classroom.semester %>
</p>
10 changes: 5 additions & 5 deletions app/views/classrooms/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Classroom Info
<p>
<%= @classroom.course_name %>
<%= @classroom.semester %>
</p>

<%= render partial: "classroom", locals: {classroom: @classroom } %>
<% @classroom.students.each do |student| %>
<%= render partial: 'students/student', locals: {student: student} %>
<% end %>
2 changes: 1 addition & 1 deletion app/views/students/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= form_for @student do |f|%>
<%= form_for student do |f|%>
<p>
<%= f.label :name %>
<%= f.text_field :name %>
Expand Down
6 changes: 3 additions & 3 deletions app/views/students/_student.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<ul>
<li>
Name: <%= @student.name %>
Name: <%= student.name %>
</li>
<li>
Birthday: <%= @student.birthday.strftime("%m/%d/%Y") %>
Birthday: <%= student.birthday.strftime("%m/%d/%Y") %>
</li>
<li>
Hometown: <%= @student.hometown.capitalize %>
Hometown: <%= student.hometown.capitalize %>
</li>
</ul>
2 changes: 1 addition & 1 deletion app/views/students/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<%= render 'form' %>
<%= render partial: 'form', locals: {student: @student } %>
5 changes: 5 additions & 0 deletions app/views/students/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h1>Students</h1>

<%= @students.each do |s| %>
<%= render partial: "student", locals: {student: s} %>
<% end %>
2 changes: 1 addition & 1 deletion app/views/students/new.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<%= render 'form' %>
<%= render partial: 'form', locals: {student: @student}%>
2 changes: 1 addition & 1 deletion app/views/students/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<h1>Student Info</h1>

<%= render 'student' %>
<%= render :partial => 'student', locals: {student: @student } %>