Head First Rails by David Griffiths Copyright © 2009 O’Reilly Media, Inc. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly Media books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (safari.oreilly.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or
[email protected] Series Creators: Kathy Sierra, Bert Bates Series Editor: Brett D. McLaughlin Editors: Brett D. McLaughlin, Louise Barr Design Editor: Louise Barr Cover Designers: Louise Barr, Steve Fehler Production Editor: Brittany Smith Proofreader: Matt Proud Indexer: Julie Hawks Page Viewers: Dawn Griffiths, Friski the Wi-fi Bunny Printing History: December 2008: First Edition. Friski the Wi-fi bunny Dawn Griffiths The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. The Head First series designations, Head First Rails, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and the authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. No stick figures were harmed in the making of this book. TM This book uses RepKover™, a durable and flexible lay-flat binding. ISBN: 978-0-596-51577-5 [M] 8 XML and multiple representations It all looks different now... Heavens - you’ve really changed, Dorothy. You can’t please everyone all of the time. Or can you? So far we’ve looked at how you can use Rails to quickly and easily develop web apps that perfectly fit one set of requirements. But what do you do when other requirements come along? What should you do if some people want basic web pages, others want a Google mashup, and yet more want your app available as an RSS feed? In this chapter you’ll create multiple representations of the same basic data, giving you the maximum flexibility with minimum effort.