Ruby on Rails Power!: The Comprehensive Guide

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Ruby on Rails is a feature-rich, easy to learn, and powerful web application framework that makes creating sophisticated, full featured web applications a snap. With the intuitive, straightforward nature of Ruby and the development platform provided by Rails, anyone can put together full-fledged web applications quickly, even if they're new to web programming. Ruby on Rails Power! is a comprehensive introduction to both the Ruby language and the Ruby on Rails framework, providing you with everything you need to author the next successful Web 2.0 application. It starts with the basics: installing Ruby, Ruby on Rails, and MySQL, and building a simple application in Rails. Then, since the Ruby on Rails framework is powered by the Ruby language, the book moves on to cover the basics of Ruby, making the learning curve for Ruby on Rails much easier to navigate. From there, the fundamentals everyone needs to develop a robust web application in Rails are covered in depth, from creating an interface to create, retrieve, update and delete records in a database with the Rails scaffold generator, to understanding the Model View Controller paradigm (Active Record, Action Controller and Action View) and using web services, AJAX, and Adobe Flex. By the end of the book, you?'ll have created numerous applications in Rails, including a blog, a wiki, and a forum.

Author(s): Aneesha Bakharia
Edition: 1
Year: 2007

Language: English
Pages: 417

Table of Contents......Page 8
Ruby on Rails Fundamental Concepts......Page 20
The Model View Controller Paradigm......Page 22
Installing Ruby, Rails, and MySQL......Page 23
Installing Ruby......Page 24
Installing MySQL......Page 25
Creating a Ruby on Rails Project......Page 26
Exploring the Ruby on Rails Directory Structure......Page 27
Using the Webrick Web Server......Page 29
Controllers, Actions, and Views......Page 31
Using Embedded Ruby (ERb)......Page 33
Linking to Actions......Page 36
Displaying Random Images......Page 37
Generating Your Own Ruby on Rails API Documentation......Page 39
Joining the Rails Community......Page 40
Conclusion......Page 41
Ruby Syntax......Page 42
Interactive Ruby: irb......Page 43
Using the Ruby Interpreter......Page 44
Variables, Constants, and Assignment......Page 45
Objects and Data Types......Page 46
Strings......Page 47
Mathematical Operations......Page 49
Generating Random Numbers......Page 50
Conditional Processing......Page 51
Loops......Page 53
Arrays......Page 54
Hashes......Page 57
Functions......Page 58
Classes and Methods......Page 59
Handling Exceptions......Page 63
Embedded Ruby......Page 65
Using Webrick to Serve ERb Templates......Page 68
Conclusion......Page 70
Creating a Contact List......Page 72
Creating an FAQ Manager......Page 84
Creating a Weblog......Page 91
Conclusion......Page 100
Migrations......Page 102
Adding and Removing Columns from a Table......Page 106
Altering Columns in a Table......Page 109
Defining Indices......Page 110
Working with Active Record Models......Page 111
Using Active Record Without Rails......Page 114
Retrieving Records with find......Page 115
Using find_by_sql......Page 116
Column Statistics—Average, Max, Min, Sum, and Count......Page 119
Validation......Page 120
Mapping Relationships with Active Record......Page 125
One-to-One Relationships......Page 126
One-to-Many Relationships......Page 127
Many-to-Many Relationships......Page 128
Sorting with acts_as_list......Page 129
Hierarchies with acts_as_tree......Page 133
Timestamping Records......Page 137
Conclusion......Page 139
Processing Form Elements......Page 140
Retrieving Environment Variables......Page 144
Exploring the Render Method......Page 146
Using an Action to Generate Files......Page 148
Redirection......Page 149
Cookies......Page 150
Sessions......Page 151
Using the Flash......Page 152
Routing......Page 153
Creating a Date-Based Routing Rule for a Weblog......Page 155
Changing an Application’s Default Page......Page 156
Using the Rails Console to Test Routing Rules......Page 157
Conclusion......Page 158
Embedded Ruby (ERb) and Templates......Page 160
Passing Objects and Variables to a Template......Page 162
Creating Helpers......Page 163
Rails Inbuilt Helpers......Page 164
Creating Links......Page 166
Including Template-Specific Content in a Layout......Page 168
Including Scripts and Style Sheets in a Layout......Page 169
Partials and Collections......Page 170
Using Helpers to Create Forms......Page 171
Select Boxes......Page 175
Modeless Forms......Page 176
Conclusion......Page 177
Validating XML......Page 178
Parsing an XML Document......Page 179
Generating XML......Page 180
REST-Style Web Services......Page 182
XML-RPC......Page 185
Searching Google with WSDL......Page 187
Building RESTful Web Services with Rails......Page 189
Using the scaffold_resource Generator......Page 190
Using ActionWebService to Expose SOAP and XML-RPC Web Services......Page 200
Conclusion......Page 204
What Is AJAX Anyway?......Page 206
The XMLHttpRequest Object......Page 207
Updating Multiple Page Elements with RJS......Page 233
Conclusion......Page 236
Download and Install the Flex 2 SDK......Page 238
A Simple Flex Interface with MXML......Page 240
Interface Design with Flex......Page 243
Using a Slider Control to Resize an Image......Page 244
Displaying a Series of Images......Page 246
Creating a Drag-and-Drop Image Classifier......Page 248
Using the DataGrid Control to Display XML......Page 252
Exposing an Active Record Model as XML......Page 254
Adding an Employee......Page 258
Deleting an Employee......Page 261
Updating an Employee......Page 265
Conclusion......Page 270
Action Mailer Configuration......Page 272
Graphs......Page 293
Conclusion......Page 297
Plug-In Installation......Page 298
Versioning with acts_as_versioned......Page 299
Folksonomy with acts_as_taggable......Page 302
Commenting with acts_as_commentable......Page 307
Searching with acts_as_ferret......Page 309
Generating PDF Documents......Page 310
Conclusion......Page 312
Filters......Page 314
Authentication with Filters......Page 315
Using a before_filter to Log Actions......Page 321
Using an around_filter to Time Actions......Page 322
Caching......Page 323
Useful String Extensions......Page 327
Date and Time Calculations......Page 328
Convert an Object to JSON or YAML......Page 329
Fun with Arrays......Page 330
Numeric Enhancements......Page 331
Pluralization......Page 332
Conclusion......Page 333
Using the Ruby Unit Testing Framework (Test::Unit)......Page 334
Setting Up the Test Database......Page 338
Testing in Rails......Page 339
Unit Testing Models......Page 340
Using Fixtures......Page 343
Functional Testing Controllers......Page 345
Posting Form Data......Page 349
Scaffolding and Functional Testing......Page 351
Authentication......Page 353
Integration Testing......Page 355
Code Coverage......Page 357
Using the debug Helper......Page 359
Using the Built-In Logger Class......Page 360
Checking Code for Syntax Errors......Page 361
Conclusion......Page 362
Features......Page 364
Layout......Page 365
Setup......Page 367
Creating the Model and Database......Page 368
The Controller and View......Page 369
Using the Wiki......Page 381
Enhancements......Page 383
Setup......Page 384
Creating the Model and Database......Page 385
The Controller and View......Page 386
Conclusion......Page 392
Command Line Ruby......Page 394
Strings......Page 395
Conditional Constructs......Page 396
Loops......Page 397
Arrays......Page 398
Hashes......Page 399
Classes......Page 401
Appendix B: Ruby on Rails Quick Reference......Page 402
A......Page 406
D......Page 407
F......Page 408
H......Page 409
M......Page 410
O......Page 411
R......Page 412
T......Page 413
W......Page 414
Z......Page 415