Coder Social home page Coder Social logo

partial-locals-lab-v-000's Introduction

Partials with Locals Lab

Objectives

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

Overview

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.

Your team lead also asked for a couple new features.

  1. Display all students on the classroom show page, and stop displaying a special note about the oldest student. The lead engineer, being old himself, thinks that this isn't polite.

  2. Add some search functionality so that a user can search for a classroom and see that classroom's show page. He requests that we use partials to render each matching result's classroom information.

Instructions

  1. Refactor the _form.html.erb partial to pass through the form object as a local. Because the form block will start on both the students/new and students/edit pages, let's rename our partial from _form.html.erb to _fields.html.erb as now it will contain all of the fields (and the submit button).

  2. Refactor the _student.html.erb partial to pass through each 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. Add in search functionality such that users can search for a course by subject and see all matching results. The results should be displayed by rendering a classrooms/_classroom.html.erb partial.

View this lesson on Learn.co

partial-locals-lab-v-000's People

Contributors

blake41 avatar jeffkatzy avatar jmburges avatar annjohn avatar onyoo avatar

Watchers

James Cloos avatar  avatar

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.