Rails for .NET Developers - Cohen_ Jeff.pdf

(2529 KB) Pobierz
164404949 UNPDF
164404949.013.png
What readers are saying about Rails for .NET Developers
Eng and Cohen, like a modern-day Lewis and Clark, have blazed a
trail that .NET developers can follow to the new frontier. If you are
a .NET developer and are considering moving to Ruby on Rails, then
this book is the place to start.
James Avery
President and CEO, Infozerk, Inc.
If you’re ready to make the rewarding trip from .NET to Rails, this
book will give you the road map you need.
Mike Gunderloy
Former .NET Developer, http://afreshcup.com
This book will be a tremendous aid to anyone making the transition
from .NET to Ruby on Rails. All the major topics a new Rails developer
should become familiar with are covered in great detail.
Michael Leung
Lead Developer, Urbis.com
Jeff and Brian have done a wonderful job of explaining Ruby on Rails
to .NET developers in this book...but there’s more value here than just
learning a hot technology. Jeff and Brian show you how Ruby on Rails
can make you a better developer no matter what platform you use, as
well as how it can influence how you design and write web applica-
tions.
Brian Hogan
Principal Consultant, New Auburn Personal Computer
Services LLC
164404949.014.png
Rails for .NET Developers
Jeff Cohen
Brian Eng
The Pragmatic Bookshelf
Raleigh, North Carolina Dallas, Texas
 
Many of the designations used by manufacturers and sellers to distinguish their prod-
ucts 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 © 2008 Jeff Cohen and Brian Eng.
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-10: 1-934356-20-4
ISBN-13: 978-1-934356-20-3
164404949.015.png 164404949.001.png 164404949.002.png 164404949.003.png 164404949.004.png 164404949.005.png 164404949.006.png 164404949.007.png 164404949.008.png 164404949.009.png 164404949.010.png 164404949.011.png 164404949.012.png
Contents
8
9
What’s in This Book . . . . . . . . . . . . . . . . . . . . . . . .
9
Who This Book Is For . . . . . . . . . . . . . . . . . . . . . . . .
10
10
Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11
Online Resources . . . . . . . . . . . . . . . . . . . . . . . . . .
11
12
13
1.1
Why Rails? . . . . . . . . . . . . . . . . . . . . . . . . . .
13
1.2
Culture Shock and Its Treatment . . . . . . . . . . . . .
15
1.3
Let’s Get This Party Started . . . . . . . . . . . . . . . .
17
1.4
Installing Ruby and Rails . . . . . . . . . . . . . . . . .
18
1.5
Connecting to a Database . . . . . . . . . . . . . . . . .
21
1.6
22
31
2.1
Ruby vs. .NET for the Impatient . . . . . . . . . . . . . .
32
2.2
Our First Ruby Program . . . . . . . . . . . . . . . . . .
34
2.3
Working with String Objects . . . . . . . . . . . . . . . .
35
2.4
irb Is Your New “Immediate Mode” . . . . . . . . . . . .
38
2.5
Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
38
2.6
Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . .
44
2.7
Hashes . . . . . . . . . . . . . . . . . . . . . . . . . . . .
46
2.8
Everything Is an Object . . . . . . . . . . . . . . . . . . .
48
2.9
Classes and Objects . . . . . . . . . . . . . . . . . . . . .
50
2.10 Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
56
 
Zgłoś jeśli naruszono regulamin