Skip to content

rcho100/partial-locals-lab-v-000

This branch is 2 commits ahead of, 14 commits behind learn-co-students/partial-locals-lab-v-000:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
github username
Aug 27, 2019
3b06246 · Aug 27, 2019

History

35 Commits
Aug 27, 2019
Feb 13, 2019
Aug 27, 2019
Aug 27, 2019
Jan 20, 2016
Jan 20, 2016
Jan 20, 2016
Aug 8, 2019
Jan 20, 2016
Mar 7, 2019
Aug 30, 2018
Jan 20, 2016
Aug 30, 2018
Feb 13, 2019
Aug 27, 2019
Aug 30, 2018
Aug 30, 2018
Jan 20, 2016
Jan 20, 2016

Repository files navigation

Partials with Locals

Now that we learned about locals, let's refactor our old codebase and add a couple new features using this new tool.

Objectives

  1. Use the locals keyword
  2. Understand why using instance variables in partials is bad
  3. Use a partial to iterate over a collection, passing in a local
  4. Use a partial from another controller with a local

Overview

So your team's lead engineer looked over the codebase and asked you to not refer to instance variables in your partials but rather to pass through local variables. That way, your code will be more explicit about its dependencies when it calls the partial.

Also, the lead engineer asked for a couple new features.

The first is that we display all students on the classroom show page instead of singling out the oldest student with a special note. The engineer thinks this isn't very polite.

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.

Instructions

  1. Refactor the _form.html.erb partial to accept the argument to the form_for helper as a local. You'll also need to change the new.html.erb and edit.html.erb views as well.

  2. Refactor the _student.html.erb partial to pass through each rendered student as a local.

  3. On the classroom show page, iterate through each classroom's students and display each of them using our _student.html.erb partial with locals.

  4. Create a _classroom.html.erb partial to display classroom information on the classroom show page.

  5. 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.

View Partial with Locals Lab on Learn.co and start learning to code for free.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 85.3%
  • HTML 12.0%
  • CSS 1.4%
  • JavaScript 1.3%