Coder Social home page Coder Social logo

rails-video-review-deep-dive-into-nested-forms's Introduction

Deep Dive into Nested Forms- Overview

In this video lecture, we take a detailed tour through the process of building nested forms: building the form itself using HTML and Rails helper methods, structuring our params hash in a way that makes sense, and ensuring that there are writer methods on our models that receive the data from the params hash—via the controller—and instantiate objects with that data

Objectives

  • Describe forms, params, and writer methods as a game of catch
  • Use form_for to have Rails generate HTML for us
  • Understand what an ActionView::Helpers::FormBuilder object is and what it “knows” about
  • Call #local_methods on a FormBuilder object to see all of the methods that are available to it
  • Understand that every key in the params hash should correspond to a writer method
  • Know what functionality we get for “free” from our association macros, and what functionality we will need to build out ourselves (with custom writers)
  • Recognize that the convention is #something_attributes= because there will already be a writer method for #something=, and we don’t want to overwrite that
  • Practice building forms in HTML before using the Rails helpers, so that you can be really specific about what exactly you are creating
  • Understand that the accepts_nested_attributes_for macro also generates a custom writer, but is much less extensible than building that custom writer yourself
  • Instantiate objects in the controller so that fields_for inputs will show up in the view
  • Set attributes on objects instantiated in the controller so that the form can introspect on those objects’ attributes and dynamically set labels

Video

<iframe width="100%" height="720" src="https://www.youtube.com/embed/zZn0xWry6TE?rel=0&showinfo=0" frameborder="0" allowfullscreen></iframe>

View Rails Video Review: Deep Dive into Nested Forms on Learn.co and start learning to code for free.

rails-video-review-deep-dive-into-nested-forms's People

Contributors

annjohn avatar

Watchers

 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.