Git Product home page Git Product logo

partial-locals-lab's Issues

I needed to add routes for my tests to pass

Failures:

  1. Student search when it receives a search query returns all students whose names contain the given string
    Failure/Error: <%= form_tag students_path, method: :get do %>

    ActionView::Template::Error:
    undefined local variable or method `students_path' for #<#Class:0x000055ea769a2b38:0x000055ea75e86b00>
    Did you mean? @Students
    This was also casuing 7 other tests to fail for the exact same reason.

Once adding routes in for students and classrooms

Rails.application.routes.draw do

For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html

resources :classrooms
resources :students
end

It passed all tests.

The lab never specifically mentions needing to create routes, and im not sure if it has other interactions with the previous tests given i was forced to use the solution branch to try to figure out why what looked to be correct code kept failing.

Lack of specificity

Just to echo all the previous issues, the instructions to "implement search functionality" leave us guessing what the tests are actually looking for. The tests end up not even looking for something that will actually work for an end user.

You could add something simple in to make it work for the end user, for example, the path http://localhost:3000/students/?search=QUERY can be used to set @Students in the index controller by whether or not params[:search] is nil (ie Student.all vs Student.search(params[:search]). That path will already automatically be routed to the students#index action. This easily works visually in the browser and a few sentences explaining it will help students understand what the requirements are rather than digging through the spec files.

One of the reasons it is confusing is because search functionality is never actually implemented beyond the model.

Thanks!

test for search feature too loose

you can pass all of the tests without actually building the search feature. if you have partials for _student and render that partial on the student index page, plus .search method in Student class, you can pass tests without building /students/search route, #search method in students controller, search for on students index page.

Update to Faker Gem

There was an update to the Faker gem that requires the keywords 'from' and 'to" in order for rake db:seed to work. Update the code in the db/seeds.rb file to match the below

80.times do Student.create(name: Faker::Name.name, hometown: Faker::Address.city, birthday: Faker::Date.between(from: 25.years.ago, to: 18.years.ago)) end

possible to pass search spec without implementing functioning search

The student_index_spec.rb file checks for the presence of a search method and rendering of a partial--but there isn't a check to see that the search is actually implemented as described by the README ("Second, they also want to add some search functionality so that a user can search for a student by name. It's okay if other students with similar names are returned in the search results.")

It's possible to pass all specs for this lab without updating student#index in student_controller.rb to use the model's search method. i.e., leaving student#index defined as @students = Student.all. When rendered in-browser, though, the search form doesn't actually work. Not sure what test could be added...maybe one that visits students/index, fills the search form with a name, then checks that the last response does not include a name that wouldn't otherwise be returned?

Search functionality requirement is unclear

The following lines make it seem as though we need to set up a form or somehow receive user input on the students/show or students/index pages. However, this is not necessary and so the instructions are really confusing regarding what specifically we need to do, or what the desired end result is:

add some search functionality so that a user can search for a student by name. It's okay if other students with similar names are returned in the search results.
Add in search functionality such that users can search for a student by name and see all matching results on the students index page. The results should be displayed by rendering a students/_student.html.erb partial.

Missing keywords in seeds.rb

Missing keywords :from and :to in the 80.times do block

Currently:

80.times do
Student.create(name: Faker::Name.name, hometown: Faker::Address.city, birthday: Faker::Date.between(25.years.ago, 18.years.ago))
end

Should be:

80.times do
Student.create(name: Faker::Name.name, hometown: Faker::Address.city, birthday: Faker::Date.between(from: 25.years.ago, to: 18.years.ago))
end

Unable to pass variable @students from classroom controller

For the classroom#show view using the student partial, I set up my classroom controller like so:
def show
@classroom = Classroom.find(params[:id])
@Students = @classroom.students
end

I then iterated through @Students and used each individual student in the student partial. While this works in my browser as expected, the tests failed and kept giving me an error that @Students was nil. Testing it in pry and the console showed that @classroom.students gave me back a full list of students, and it showed all students in the browser.

The only way I could pass the tests was to use @classroom.students.each to iterate on the show page rather than passing the @Students variable I created in the controller. A technical coach helped me figure out the problem and suggested that it could be something specific in the tests that is not allowing the use of a variable @Students.

bullet point 5 in instructions insufficient

The method we are required to write requires knowledge of SQL "LIKE operator". Maybe there should be a hint about search queries. Otherwise, bullet point 5 is a bit out of nowhere.

Classroom Show View doesn't need oldest student

classroom_show_view
renders classroom information on the show view
renders a partial that only contains classroom (not student) information
renders a students/student partial
displays the student information from the partial

but

`
Classroom Info

<%= render partial: "classrooms/classroom", locals: {classroom: @classroom} %>

We now want to call out the oldest student in the class:
<% @classroom.students.each do |student| %>
<%= render partial: 'students/student', locals: {student: student} %>
<% end %>

##14
`

Search

It appears to me that the lesson requests a search for classrooms, but the tests are for a search for student names.

Iterating vs. rendering collection

I believe the way the spec is written is a little bottle-necky. The tests only pass if the @students variable is iterated through, versus using collections notation i.e. <%= render partial: "student", collection: @students %> . Don't they do the same thing?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.