How much change did the controller need to handle file uploads?
Why did the form_for
method 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?
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_for
method 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_column
call defining the field in
the self.up
method and a
remove_column
call in the
self.down
method.
Placing method definitions after the private
keyword 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 adding a :builder
argument to your form_for
call.
Form builders are a great idea when they let you avoid repeating yourself. Used properly, they can make it easy for an application to look consistent, even if many different developers are working on different parts of the project.