O'Reilly logo

Learning Rails: Live Edition by Edd Dumbill, Simon St. Laurent

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Test Your Knowledge

Quiz

  1. How much change did the controller need to handle file uploads?

  2. Why did the form_for method suddenly explode in complexity when the MIME type of the returned data changed?

  3. What goes into a migration when you add a field to a table?

  4. How do you make methods invisible (and uncallable) outside of their class?

  5. Are form builders for binding presentation to a specific piece of your model, or for supporting more general form construction?

  6. Do builders map to controllers automatically?

  7. Why (and when) are form builders worth the extra trouble of creating them?

Answers

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

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

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

  4. Placing method definitions after the private keyword makes them usable only within the class.

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

  6. No. Helper methods can bind to controllers through naming conventions, but using form builders requires ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required