Beginning Rails 3 - Rida Al Barazi, Cloves Carneiro Jr

Beginning Rails 3 (eBook)

eBook Download: PDF
2010 | 1st ed.
400 Seiten
Apress (Verlag)
978-1-4302-2434-1 (ISBN)
Systemvoraussetzungen
36,99 inkl. MwSt
  • Download sofort lieferbar
  • Zahlungsarten anzeigen

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.
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.

Title page 1
Copyright page 2
Contents at a Glance 4
Table of contents 5
About the Authors 15
About the Technical Reviewer 16
Acknowledgments 17
Introduction 18
The Beginning Rails Website 19
CHAPTER 1 Introducing the Rails Framework 20
The Rise and Rise of the Web Application 20
The Web Isn’t Perfect 21
The Good Web Framework 21
Enter Rails 22
Rails Is Ruby 23
Rails Encourages Agility 24
Less Software 24
Convention Over Configuration 25
Don’t Repeat Yourself 25
Rails Is Opinionated Software 26
Rails Is Open Source 26
The MVC Pattern 27
The MVC Cycle 27
The Layers of MVC 28
Models 29
Controllers 29
Views 30
The Libraries That Make Up Rails 30
Rails Is Modular 31
Rails Is No Silver Bullet 31
Summary 31
CHAPTER 2 Getting Started 32
An Overview of Rails Installation 32
Installing on Mac OS X 10.6 Snow Leopard 33
Installing the Apple Developer Tools (Xcode) 33
Updating RubyGems and Installing Rails 34
Installing on Windows 35
Installing Ruby 35
Installing Rails 36
Installing SQLite 37
Installing on Linux 38
Installing Ruby 38
Updating RubyGems 39
Installing Rails 39
Installing SQLite 40
Creating Your First Rails Application 40
Starting the Built-In Web Server 41
Generating a Controller 44
Creating an Action 45
Creating a Template 45
Summary 48
CHAPTER 3 Getting Something Running 49
An Overview of the Project 49
Creating the Blog Application 50
Creating the Project Databases 52
Creating the Article Model 54
Creating a Database Table 55
Generating a Controller 58
Up and Running with Scaffolding 59
Adding More Fields 61
Adding Validations 63
Generated Files 65
Summary 67
CHAPTER 4 Working with a Database:Active Record 68
Introducing Active Record: Object-Relational Mapping on Rails 69
What About SQL? 70
Active Record Conventions 71
Introducing the Console 71
Active Record Basics: CRUD 74
Creating New Records 75
Using the new Constructor 75
Using the create Method 77
Reading (Finding) Records 78
Finding a Single Record Using an ID 78
Finding a Single Record Using first 79
Finding All Records 80
Finding with Conditions 82
Using Dynamic Finders 82
Updating Records 83
Deleting Records 84
Using destroy 84
Using delete 85
Deleting with Conditions 86
When Good Models Go Bad 86
Summary 88
CHAPTER 5 Advanced Active Record:Enhancing Your Models 89
Adding Methods 89
Using Associations 92
Declaring Associations 93
Creating One-to-One Associations 94
Adding the User and Profile Models 94
Creating One-to-Many Associations 99
Associating User and Article Models 100
Creating a New Associated Object 102
Applying Association Options 105
Specifying a Default Order 105
Specifying Dependencies 106
Creating Many-to-Many Associations 106
Seeding Data 109
Creating Rich Many-to-Many Associations 110
Advanced Finding 113
Using the where Method 113
Using a SQL Fragment 113
Using an Array Condition Syntax 114
Using Association Proxies 116
Other Finder Methods 116
Default Scope 118
Named Scope 119
Applying Validations 121
Using Built-in Validations 121
Validating That a Value Has Been Entered 122
Validating That a Value Is Unique 122
Validating Length or Size 123
Validating the Format of an Attribute 124
Validating Confirmation 124
Other Validations 125
Building Custom Validation Methods 125
Making Callbacks 127
Observers 129
Updating the User Model 131
Reviewing the Updated Models 135
Summary 136
CHAPTER 6 Action Pack: Working with theView and the Controller 137
Action Pack Components 137
Action Controller 138
Action View 140
Embedded Ruby 141
Helpers 142
Routing 142
RESTful Resources 143
The Action Pack Request Cycle 144
A Controller Walk-Through 145
Setting Up Routes 145
Routing Basics 145
Named Routes 146
RESTful Routes and Resources 147
Configuring Routes for the Blog Application 148
Revisiting the Scaffold Generator 148
Rendering Responses 153
Redirecting 153
Understanding Templates 154
Working with Layouts 155
Looking at the Article Form 157
Using Form Helpers 160
Processing Request Parameters 164
Revisiting the Controller 165
Displaying Error Messages in Templates 166
Edit and Update actions 167
Revisiting the views 168
Staying DRY with Partials 169
Local Variable Assignment in Partials 170
Rendering an Object Partial 171
Rendering a Collection of Partials 171
Summary 171
CHAPTER 7 Advanced Action Pack 172
Generating a Controller 172
Nested Resources 176
Sessions and the Login/Logout Logic 182
Lying in State 183
The Shared-Nothing Architecture 183
Storing Sessions in the Database 184
Using the Session 185
Session as a Resource 185
Logging In a User 187
Logging Out a User 188
Improving Controllers and Templates 190
Cleaning Up the Articles Index Page 190
Adding Categories to the Article Form 191
Using Controller Filters 194
Requiring Authentication with Filters 195
Applying Filters to Controllers 196
Adding Finishing Touches 199
Using Action View Helpers 199
Escaping HTML in Templates 200
Formatting the Body Field 202
Adding Edit Controls 202
Making Sure Articles Have Owners 204
Adding Custom Helpers 206
Giving It Some Style 208
Updating the Layout 208
Applying a Style Sheet 209
Summary 214
CHAPTER 8 Improving Interaction with Ajax 215
Ajax and Rails 215
Prototype and jQuery 216
Installing jQuery 216
jQuery and DOM 217
Moving to Practice 218
Not All Users Comment 218
Loading a Template via Ajax 218
Responding to Requests with :format => :js
Making a Grand Entrance 221
Using Ajax for Forms 222
Deleting Records with Ajax 225
Summary 227
CHAPTER 9 Sending and Receiving E-Mail 228
Setting Up Action Mailer 228
Configuring Mail Server Settings 228
Configuring Application Settings 231
Sending E-Mail 231
Handling Basic E-Mail 233
Sending HTML E-Mail 239
Adding Attachments 241
Letting Authors Know About Comments 242
Receiving E-Mail 243
Using a Rails Process 244
Reading E-Mail Using POP or IMAP 244
Summary 245
CHAPTER 10 Testing Your Application 246
How Rails Handles Testing 246
Unit Testing Your Rails Application 248
Testing the Article Model 249
Creating Fixtures 249
Adding a Create Test 250
Testing with Assertions 251
Adding a Find Test 252
Adding an Update Test 253
Adding a Destroy Test 254
Testing Validations 255
Functional Testing Your Controllers 257
Testing the Articles Controller 257
Creating a Test Helper 258
Testing the Index Action 259
Testing the Show Action 261
Testing the New Action 263
Testing the Create Action 265
Testing the Destroy Action 268
One Missing Test 270
Running the Full Test Suite 270
Integration Testing 272
Integration-Testing the Blog Application 272
Story-Based Testing 276
Running the Full Test Suite 280
Summary 281
CHAPTER 11 Internationalization 282
Internationalization Logic in Rails 282
Setting Up i18n in the Blog Application 285
Localizing the Blog Application to Brazilian Portuguese 290
Bilingual Blog 293
Summary 297
CHAPTER 12 Extending Rails with Plug-ins 298
Finding and Installing Plug-ins 298
Finding Plug-ins 300
Installing Plug-ins 300
Using a Plug-in in Your Application 301
Modifying the Database 302
Modifying the Application to Use the Plug-in 303
Creating Your Own Plug-in 307
Creating the Plug-in Module 309
Making the Plug-in Available to Applications 310
Using SimpleSearch 310
Testing the Plug-in 311
Updating the Controller and Views 313
Summary 319
CHAPTER 13 Deploying Your Rails Applications 320
Deploying with Capistrano 320
Capistrano Installation 321
Capistrano Recipes 323
Capistrano on the Deployment Server 325
Custom Capistrano Tasks 326
Setting Up Your Server Architecture 326
Modular Architecture 326
Picking a Web Server 327
Becoming an Instant Deployment Expert 327
Summary 328
APPENDIX A Ruby, a Programmer’s Best Friend 329
Instant Interaction 329
Ruby Data Types 330
Strings 330
Numbers 331
Symbols 332
Arrays and Hashes 332
Language Basics 333
Variables 334
Operators 335
Blocks and Iterators 335
Control Structures 337
Methods 338
Classes and Objects 339
Objects 339
Classes 340
Ruby Documentation 342
APPENDIX B Databases 101 344
Examining a Database Table 344
Working with Tables 345
Selecting Data 346
Inserting Data 347
Updating Data 348
Deleting Data 348
Understanding Relationships 349
SQL and Active Record 351
APPENDIX C The Rails Community 352
Beginning Rails 3 Channels 352
Rails Mailing Lists 352
Rails IRC Channel 353
Rails Blogs and Podcasts 353
Rails Guides 354
Rails Wiki 354
Rails APIs 354
Rails Source and Issue Tracking 354
Working with Rails Directory 355
APPENDIX D Git 356
What Is Source Control Management? 356
How Does It Work? 356
Git 357
Installing Git 357
Installing on Windows 357
Installing on Mac OS X 358
Installing on Linux 358
Setting Global Parameters 358
Initializing a Repository 359
Ignoring Files 361
Adding and Committing 361
Branching and Merging 363
Remote Repositories and Cloning 368
Learning More 369
Other SCM Systems 370
Online Resources 371
Index 372

Erscheint lt. Verlag 31.12.2010
Zusatzinfo 400 p.
Verlagsort Berkeley
Sprache englisch
Themenwelt Mathematik / Informatik Informatik Programmiersprachen / -werkzeuge
Mathematik / Informatik Informatik Theorie / Studium
Mathematik / Informatik Informatik Web / Internet
Schlagworte AJAX • E-Mail • Framework • interaction • Rest • Ruby On Rails
ISBN-10 1-4302-2434-7 / 1430224347
ISBN-13 978-1-4302-2434-1 / 9781430224341
Haben Sie eine Frage zum Produkt?
PDFPDF (Wasserzeichen)
Größe: 2,1 MB

DRM: Digitales Wasserzeichen
Dieses eBook enthält ein digitales Wasser­zeichen und ist damit für Sie persona­lisiert. Bei einer missbräuch­lichen Weiter­gabe des eBooks an Dritte ist eine Rück­ver­folgung an die Quelle möglich.

Dateiformat: PDF (Portable Document Format)
Mit einem festen Seiten­layout eignet sich die PDF besonders für Fach­bücher mit Spalten, Tabellen und Abbild­ungen. Eine PDF kann auf fast allen Geräten ange­zeigt werden, ist aber für kleine Displays (Smart­phone, eReader) nur einge­schränkt geeignet.

Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen dafür einen PDF-Viewer - z.B. den Adobe Reader oder Adobe Digital Editions.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen dafür einen PDF-Viewer - z.B. die kostenlose Adobe Digital Editions-App.

Zusätzliches Feature: Online Lesen
Dieses eBook können Sie zusätzlich zum Download auch online im Webbrowser lesen.

Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.

Mehr entdecken
aus dem Bereich
Das Handbuch für Webentwickler

von Philip Ackermann

eBook Download (2023)
Rheinwerk Computing (Verlag)
49,90
Das umfassende Handbuch

von Johannes Ernesti; Peter Kaiser

eBook Download (2023)
Rheinwerk Computing (Verlag)
44,90
Mit über 150 Workouts in Java und Python

von Luigi Lo Iacono; Stephan Wiefling; Michael Schneider

eBook Download (2023)
Carl Hanser Verlag GmbH & Co. KG
29,99