Rails Recipes (2006).pdf

(2452 KB) Pobierz
Rails Recipes
Prepared exclusively for Hilairo Vega Coronel
44013053.018.png
Book
Agile publishing for agile developers
The book you’re reading is still under development. As an experiment,
we’re releasing this copy well before we normally would. That way
you’ll be able to get this content a couple of months before it’s avail-
able in finished form, and we’ll get feedback to make the book even
better. The idea is that everyone wins!
Be warned. The book has not had a full technical edit, so it will con-
tain errors. It has not been copyedited, so it will be full of typos.
And there’s been no effort spent doing layout, so you’ll find bad page
breaks, over-long lines, incorrect hyphenations, and all the other ugly
things that you wouldn’t expect to see in a finished book. We can’t
be held liable if you use this book to try to create a spiffy application
and you somehow end up with a strangely shaped farm implement
instead. Despite all this, we think you’ll enjoy it!
Throughout this process you’ll be able to download updated
the book is finally ready, you’ll get the final version (and sub-
sequent updates) from the same address. In the meantime,
we’d appreciate you sending us your feedback on this book at
Thank you for taking part in this experiment.
Dave Thomas
Prepared exclusively for Hilairo Vega Coronel
Beta
44013053.019.png 44013053.020.png
Rails Recipes
Chad Fowler
The Pragmatic Bookshelf
Raleigh, North Carolina Dallas, Texas
Prepared exclusively for Hilairo Vega Coronel
44013053.021.png
 
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 The
Pragmatic Programmers, LLC was aware of a trademark claim, the designations have
been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The
Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf and the linking g
device are trademarks of The Pragmatic Programmers, LLC.
Every precaution was taken in the preparation of this book. However, the publisher
assumes no responsibility for errors or omissions, or for damages that may result from
the use of information (including program listings) contained herein.
Our Pragmatic courses, workshops, and other products can help you and your team
create better software and have more fun. For more information, as well as the latest
Pragmatic titles, please visit us at
Copyright © 2006 The Pragmatic Programmers LLC.
All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmit-
ted, in any form, or by any means, electronic, mechanical, photocopying, recording, or
otherwise, without the prior consent of the publisher.
Printed in the United States of America.
ISBN 0-9776166-0-6
Printed on acid-free paper with 85% recycled, 30% post-consumer content.
B1.3 printing, March 16, 2006
Version: 2006-4-11
Prepared exclusively for Hilairo Vega Coronel
44013053.001.png 44013053.002.png 44013053.003.png 44013053.004.png 44013053.005.png 44013053.006.png 44013053.007.png 44013053.008.png 44013053.009.png 44013053.010.png 44013053.011.png 44013053.012.png 44013053.013.png 44013053.014.png 44013053.015.png 44013053.016.png 44013053.017.png
Contents
1
1.1 What Makes a Good Recipe Book? . . . . . . . . . . . . .
1
1.2 Who’s It For? . . . . . . . . . . . . . . . . . . . . . . . . .
2
1.3 Rails Version . . . . . . . . . . . . . . . . . . . . . . . . .
2
1.4 Resources . . . . . . . . . . . . . . . . . . . . . . . . . . .
2
1.5 Acknowledgments . . . . . . . . . . . . . . . . . . . . . .
3
1.6 Tags and Thumbtabs . . . . . . . . . . . . . . . . . . . .
5
6
1.
In-Place Form Editing . . . . . . . . . . . . . . . . . . . .
7
2.
Making Your Own JavaScript Helper . . . . . . . . . . .
13
3.
Live Preview . . . . . . . . . . . . . . . . . . . . . . . . . .
20
4.
Live Search . . . . . . . . . . . . . . . . . . . . . . . . . .
23
5.
26
6.
Update Multiple Page Elements With One Ajax Request
32
7.
38
8.
Cheap and Easy Theme Support . . . . . . . . . . . . . .
43
9.
Use Ajax To Trim Fat, Static Pages . . . . . . . . . . . .
44
10. Smart Pluralization . . . . . . . . . . . . . . . . . . . . .
45
11. Debugging Ajax . . . . . . . . . . . . . . . . . . . . . . . .
46
12. Creating a Custom Form Builder . . . . . . . . . . . . .
48
13. Make Pretty Graphs . . . . . . . . . . . . . . . . . . . . .
52
56
14. Rails Without A Database . . . . . . . . . . . . . . . . . .
57
15. Connecting to Multiple Databases . . . . . . . . . . . . .
61
16. Integrating with Legacy Databases . . . . . . . . . . . . .
69
72
74
19. Tagging . . . . . . . . . . . . . . . . . . . . . . . . . . . .
77
Prepared exclusively for Hilairo Vega Coronel
 
Zgłoś jeśli naruszono regulamin