Test Your Knowledge
Quiz
How much change did the controller need to handle file uploads?
Why did the
form_formethod suddenly explode in complexity when the MIME type of the returned data changed?What goes into a migration when you add a field to a table?
How do you make methods invisible (and uncallable) outside of their class?
Are form builders for binding presentation to a specific piece of your model, or for supporting more general form construction?
Do builders map to controllers automatically?
Why (and when) are form builders worth the extra trouble of creating them?
Answers
The controller needed no change at all. All of the changes were in the views, to give users the ability to upload and display the file, and in the model, to handle the file when it arrived and when it was needed.
The
form_formethod looks much more complex because we’d been using a simplified form of it that assumes a lot of defaults. Change those defaults, and you need to specify much, much more.A migration that adds a field needs an
add_columncall defining the field in theself.upmethod and aremove_columncall in theself.downmethod.Placing method definitions after the
privatekeyword makes them usable only within the class.They can be used for both general form construction and the creation of reusable components tightly bound to a particular model. You can even mix the two approaches in the same class.
No. Helper methods can bind to controllers through naming conventions, but using form builders requires ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access