Skip to Main Content
Learning Rails
book

Learning Rails

by Simon St. Laurent, Edd Dumbill
November 2008
Beginner content levelBeginner
448 pages
12h 25m
English
O'Reilly Media, Inc.
Content preview from Learning Rails

Standardizing Your Look with Form Builders

While Rails scaffolding is a convenient way to get started, you may have noticed that it’s pretty repetitive and not especially attractive. Some of this can be fixed with judicious use of CSS, but Rails supports more permanent fixes through the use of form builders. Creating form builders is an opportunity to define how your data will be presented to users and how they’ll interact with that data. Form builders also let you create abstractions that keep programmers out of the visual details of your application while still giving them full access to views.

The basic concepts behind form builders are simple, though you can use them to create complex and intricate components. You can use form builders in multiple ways, starting from simple wrapping of your own special types and developing through more complex ways to change the ways forms are written.

Note

You can also combine form builders with Ruby metaprogramming to create your own terse yet descriptive syntaxes for creating forms, but metaprogramming is way beyond the scope of this book. If you encounter an application with view code that looks nothing like you expected, though, that may be what’s going on.

Supporting Your Own Field Types

Chapter 6 showed how Rails supported a variety of data types by default, including a more complicated (if not very user-friendly) set of controls for entering dates. While the built-in set of widgets is helpful, you’re definitely not limited to it. You can ...

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.
Start your free trial

You might also like

Learning Rails 5

Learning Rails 5

J. Mark Locklear, Eric J Gruber, Barnabas Bulpett
Mastering Ruby Closures

Mastering Ruby Closures

Benjamin Tan Wei Hao
Ruby on Rails® Bible

Ruby on Rails® Bible

Timothy Fisher

Publisher Resources

ISBN: 9780596154943Supplemental ContentErrata