E-Book, Englisch, 400 Seiten
Al Barazi / Carneiro Jr Beginning Rails 3
1. ed
ISBN: 978-1-4302-2434-1
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark
E-Book, Englisch, 400 Seiten
ISBN: 978-1-4302-2434-1
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark
Beginning Rails 3 is the practical starting point for anyone wanting to learn how to build dynamic web applications using the Rails framework for Ruby. You'll learn how all of the components of Rails fit together and how you can leverage them to create sophisticated web applications with less code and more joy. This book is particularly well suited to those with little or no experience with web application development, or who have some experience but are new to Rails. Beginning Rails 3 assumes basic familiarity with web terms and technologies, but doesn't require you to be an expert. Rather than delving into the arcane details of Rails, the focus is on the aspects of the framework that will become your pick, shovel, and axe. Part history lesson, part introduction to object-oriented programming, and part dissertation on open source software, this title doesn't just explain how to do something in Rails, it explains why. Learn to create Rails web applications from scratch Includes a gentle introduction to the Ruby programming language Completely updated to include the features of Rails 3
Rida Al Barazi is a passionate web developer experienced in building smart web applications for startups. He has been designing and building for the web since 2002. He started working with Rails in 2005 and spoke at different web and Rails conferences in Europe and the Middle East.Rida was raised in Kuwait, grew up in Syria, started his career in Dubai and currently lives in Toronto. In his free time he enjoys music, concerts, movies, traveling and meeting new people. Rida's contact information can be found on his website, www.rida.me.
Autoren/Hrsg.
Weitere Infos & Material
1;Title page ;1
2;Copyright page ;2
3;Contents at a Glance;4
4;Table of contents ;5
5;About the Authors;15
6;About the Technical Reviewer;16
7;Acknowledgments;17
8;Introduction;18
9;The Beginning Rails Website;19
10;CHAPTER 1 Introducing the Rails Framework;20
10.1;The Rise and Rise of the Web Application;20
10.2;The Web Isn’t Perfect;21
10.3;The Good Web Framework;21
10.4;Enter Rails;22
10.4.1;Rails Is Ruby;23
10.4.2;Rails Encourages Agility;24
10.4.2.1;Less Software;24
10.4.2.2;Convention Over Configuration;25
10.4.2.3;Don’t Repeat Yourself;25
10.4.3;Rails Is Opinionated Software;26
10.4.4;Rails Is Open Source;26
10.5;The MVC Pattern;27
10.5.1;The MVC Cycle;27
10.5.2;The Layers of MVC;28
10.5.2.1;Models;29
10.5.2.2;Controllers;29
10.5.2.3;Views;30
10.6;The Libraries That Make Up Rails;30
10.7;Rails Is Modular;31
10.8;Rails Is No Silver Bullet;31
10.9;Summary;31
11;CHAPTER 2 Getting Started;32
11.1;An Overview of Rails Installation;32
11.2;Installing on Mac OS X 10.6 Snow Leopard;33
11.2.1;Installing the Apple Developer Tools (Xcode);33
11.2.2;Updating RubyGems and Installing Rails;34
11.3;Installing on Windows;35
11.3.1;Installing Ruby;35
11.3.2;Installing Rails;36
11.3.3;Installing SQLite;37
11.4;Installing on Linux;38
11.4.1;Installing Ruby;38
11.4.2;Updating RubyGems;39
11.4.3;Installing Rails;39
11.4.4;Installing SQLite;40
11.5;Creating Your First Rails Application;40
11.5.1;Starting the Built-In Web Server;41
11.5.2;Generating a Controller;44
11.5.3;Creating an Action;45
11.5.4;Creating a Template;45
11.6;Summary;48
12;CHAPTER 3 Getting Something Running;49
12.1;An Overview of the Project;49
12.2;Creating the Blog Application;50
12.2.1;Creating the Project Databases;52
12.2.2;Creating the Article Model;54
12.2.3;Creating a Database Table;55
12.2.4;Generating a Controller;58
12.2.5;Up and Running with Scaffolding;59
12.2.6;Adding More Fields;61
12.2.7;Adding Validations;63
12.2.8;Generated Files;65
12.3;Summary;67
13;CHAPTER 4 Working with a Database:Active Record;68
13.1;Introducing Active Record: Object-Relational Mapping on Rails;69
13.1.1;What About SQL?;70
13.1.2;Active Record Conventions;71
13.2;Introducing the Console;71
13.3;Active Record Basics: CRUD;74
13.3.1;Creating New Records;75
13.3.1.1;Using the new Constructor;75
13.3.1.2;Using the create Method;77
13.3.2;Reading (Finding) Records;78
13.3.2.1;Finding a Single Record Using an ID;78
13.3.2.2;Finding a Single Record Using first;79
13.3.2.3;Finding All Records;80
13.3.2.4;Finding with Conditions;82
13.3.2.5;Using Dynamic Finders;82
13.3.3;Updating Records;83
13.3.4;Deleting Records;84
13.3.4.1;Using destroy;84
13.3.4.2;Using delete;85
13.3.4.3;Deleting with Conditions;86
13.4;When Good Models Go Bad;86
13.5;Summary;88
14;CHAPTER 5 Advanced Active Record:Enhancing Your Models;89
14.1;Adding Methods;89
14.2;Using Associations;92
14.2.1;Declaring Associations;93
14.2.2;Creating One-to-One Associations;94
14.2.2.1;Adding the User and Profile Models;94
14.2.3;Creating One-to-Many Associations;99
14.2.3.1;Associating User and Article Models;100
14.2.3.2;Creating a New Associated Object;102
14.2.4;Applying Association Options;105
14.2.4.1;Specifying a Default Order;105
14.2.4.2;Specifying Dependencies;106
14.2.5;Creating Many-to-Many Associations;106
14.2.5.1;Seeding Data;109
14.2.6;Creating Rich Many-to-Many Associations;110
14.3;Advanced Finding;113
14.3.1;Using the where Method;113
14.3.2;Using a SQL Fragment;113
14.3.3;Using an Array Condition Syntax;114
14.3.4;Using Association Proxies;116
14.3.5;Other Finder Methods;116
14.3.6;Default Scope;118
14.3.7;Named Scope;119
14.4;Applying Validations;121
14.4.1;Using Built-in Validations;121
14.4.1.1;Validating That a Value Has Been Entered;122
14.4.1.2;Validating That a Value Is Unique;122
14.4.1.3;Validating Length or Size;123
14.4.1.4;Validating the Format of an Attribute;124
14.4.1.5;Validating Confirmation;124
14.4.1.6;Other Validations;125
14.4.2;Building Custom Validation Methods;125
14.5;Making Callbacks;127
14.6;Observers;129
14.6.1;Updating the User Model;131
14.7;Reviewing the Updated Models;135
14.8;Summary;136
15;CHAPTER 6 Action Pack: Working with theView and the Controller;137
15.1;Action Pack Components;137
15.1.1;Action Controller;138
15.1.2;Action View;140
15.1.3;Embedded Ruby;141
15.1.4;Helpers;142
15.1.5;Routing;142
15.1.6;RESTful Resources;143
15.1.7;The Action Pack Request Cycle;144
15.2;A Controller Walk-Through;145
15.2.1;Setting Up Routes;145
15.2.1.1;Routing Basics;145
15.2.1.2;Named Routes;146
15.2.1.3;RESTful Routes and Resources;147
15.2.1.4;Configuring Routes for the Blog Application;148
15.2.2;Revisiting the Scaffold Generator;148
15.2.3;Rendering Responses;153
15.2.4;Redirecting;153
15.2.5;Understanding Templates;154
15.2.6;Working with Layouts;155
15.2.7;Looking at the Article Form;157
15.2.8;Using Form Helpers;160
15.2.9;Processing Request Parameters;164
15.2.10;Revisiting the Controller;165
15.2.11;Displaying Error Messages in Templates;166
15.2.12;Edit and Update actions;167
15.2.13;Revisiting the views;168
15.2.14;Staying DRY with Partials;169
15.2.14.1;Local Variable Assignment in Partials;170
15.2.14.2;Rendering an Object Partial;171
15.2.14.3;Rendering a Collection of Partials;171
15.3;Summary;171
16;CHAPTER 7 Advanced Action Pack;172
16.1;Generating a Controller;172
16.2;Nested Resources;176
16.3;Sessions and the Login/Logout Logic;182
16.3.1;Lying in State;183
16.3.2;The Shared-Nothing Architecture;183
16.3.3;Storing Sessions in the Database;184
16.3.4;Using the Session;185
16.3.5;Session as a Resource;185
16.3.6;Logging In a User;187
16.3.7;Logging Out a User;188
16.4;Improving Controllers and Templates;190
16.4.1;Cleaning Up the Articles Index Page;190
16.4.2;Adding Categories to the Article Form;191
16.5;Using Controller Filters;194
16.5.1;Requiring Authentication with Filters;195
16.5.2;Applying Filters to Controllers;196
16.6;Adding Finishing Touches;199
16.6.1;Using Action View Helpers;199
16.6.2;Escaping HTML in Templates;200
16.6.3;Formatting the Body Field;202
16.6.4;Adding Edit Controls;202
16.6.5;Making Sure Articles Have Owners;204
16.6.6;Adding Custom Helpers;206
16.6.7;Giving It Some Style;208
16.6.7.1;Updating the Layout;208
16.6.7.2;Applying a Style Sheet;209
16.7;Summary;214
17;CHAPTER 8 Improving Interaction with Ajax;215
17.1;Ajax and Rails;215
17.1.1;Prototype and jQuery;216
17.1.1.1;Installing jQuery;216
17.1.2;jQuery and DOM;217
17.2;Moving to Practice;218
17.2.1;Not All Users Comment;218
17.2.1.1;Loading a Template via Ajax;218
17.2.1.2;Responding to Requests with :format => :js;219
17.2.1.3;Making a Grand Entrance;221
17.2.2;Using Ajax for Forms;222
17.2.3;Deleting Records with Ajax;225
17.3;Summary;227
18;CHAPTER 9 Sending and Receiving E-Mail;228
18.1;Setting Up Action Mailer;228
18.1.1;Configuring Mail Server Settings;228
18.1.2;Configuring Application Settings;231
18.2;Sending E-Mail;231
18.2.1;Handling Basic E-Mail;233
18.2.2;Sending HTML E-Mail;239
18.2.3;Adding Attachments;241
18.2.4;Letting Authors Know About Comments;242
18.3;Receiving E-Mail;243
18.3.1;Using a Rails Process;244
18.3.2;Reading E-Mail Using POP or IMAP;244
18.4;Summary;245
19;CHAPTER 10 Testing Your Application;246
19.1;How Rails Handles Testing;246
19.2;Unit Testing Your Rails Application;248
19.2.1;Testing the Article Model;249
19.2.1.1;Creating Fixtures;249
19.2.1.2;Adding a Create Test;250
19.2.1.3;Testing with Assertions;251
19.2.1.4;Adding a Find Test;252
19.2.1.5;Adding an Update Test;253
19.2.1.6;Adding a Destroy Test;254
19.2.2;Testing Validations;255
19.3;Functional Testing Your Controllers;257
19.3.1;Testing the Articles Controller;257
19.3.2;Creating a Test Helper;258
19.3.2.1;Testing the Index Action;259
19.3.2.2;Testing the Show Action;261
19.3.2.3;Testing the New Action;263
19.3.2.4;Testing the Create Action;265
19.3.2.5;Testing the Destroy Action;268
19.3.2.6;One Missing Test;270
19.3.3;Running the Full Test Suite;270
19.4;Integration Testing;272
19.4.1;Integration-Testing the Blog Application;272
19.4.2;Story-Based Testing;276
19.5;Running the Full Test Suite;280
19.6;Summary;281
20;CHAPTER 11 Internationalization;282
20.1;Internationalization Logic in Rails;282
20.2;Setting Up i18n in the Blog Application;285
20.3;Localizing the Blog Application to Brazilian Portuguese;290
20.4;Bilingual Blog;293
20.5;Summary;297
21;CHAPTER 12 Extending Rails with Plug-ins;298
21.1;Finding and Installing Plug-ins;298
21.1.1;Finding Plug-ins;300
21.1.2;Installing Plug-ins;300
21.2;Using a Plug-in in Your Application;301
21.2.1;Modifying the Database;302
21.2.2;Modifying the Application to Use the Plug-in;303
21.3;Creating Your Own Plug-in;307
21.3.1;Creating the Plug-in Module;309
21.3.2;Making the Plug-in Available to Applications;310
21.3.3;Using SimpleSearch;310
21.3.4;Testing the Plug-in;311
21.3.5;Updating the Controller and Views;313
21.4;Summary;319
22;CHAPTER 13 Deploying Your Rails Applications;320
22.1;Deploying with Capistrano;320
22.1.1;Capistrano Installation;321
22.1.2;Capistrano Recipes;323
22.1.3;Capistrano on the Deployment Server;325
22.1.4;Custom Capistrano Tasks;326
22.2;Setting Up Your Server Architecture;326
22.2.1;Modular Architecture;326
22.2.1.1;Picking a Web Server;327
22.2.2;Becoming an Instant Deployment Expert;327
22.3;Summary;328
23;APPENDIX A Ruby, a Programmer’s Best Friend;329
23.1;Instant Interaction;329
23.2;Ruby Data Types;330
23.2.1;Strings;330
23.2.2;Numbers;331
23.2.3;Symbols;332
23.2.4;Arrays and Hashes;332
23.3;Language Basics;333
23.3.1;Variables;334
23.3.2;Operators;335
23.3.3;Blocks and Iterators;335
23.3.4;Control Structures;337
23.3.5;Methods;338
23.4;Classes and Objects;339
23.4.1;Objects;339
23.4.2;Classes;340
23.5;Ruby Documentation;342
24;APPENDIX B Databases 101;344
24.1;Examining a Database Table;344
24.2;Working with Tables;345
24.2.1;Selecting Data;346
24.2.2;Inserting Data;347
24.2.3;Updating Data;348
24.2.4;Deleting Data;348
24.3;Understanding Relationships;349
24.4;SQL and Active Record;351
25;APPENDIX C The Rails Community;352
25.1;Beginning Rails 3 Channels;352
25.2;Rails Mailing Lists;352
25.3;Rails IRC Channel;353
25.4;Rails Blogs and Podcasts;353
25.5;Rails Guides;354
25.6;Rails Wiki;354
25.7;Rails APIs;354
25.8;Rails Source and Issue Tracking;354
25.9;Working with Rails Directory;355
26;APPENDIX D Git;356
26.1;What Is Source Control Management?;356
26.2;How Does It Work?;356
26.3;Git;357
26.3.1;Installing Git;357
26.3.1.1;Installing on Windows;357
26.3.1.2;Installing on Mac OS X;358
26.3.1.3;Installing on Linux;358
26.3.2;Setting Global Parameters;358
26.3.3;Initializing a Repository;359
26.3.4;Ignoring Files;361
26.3.5;Adding and Committing;361
26.3.6;Branching and Merging;363
26.3.7;Remote Repositories and Cloning;368
26.3.8;Learning More;369
26.4;Other SCM Systems;370
26.5;Online Resources;371
27;Index;372




