Rails Recipes: Rails 3 Edition, 2nd Edition


Written for novice to intermediate Rails developers, Rails Recipes: Rails 3 Edition is packed with solutions to 70 of the most vexing problems you’re likely to face on the job. From building custom forms and powering pages with JQuery to integrating with legacy databases, it’s all here. Each recipe has been updated to reflect the latest features of Rails 3.1 and each lays out a distinctive solution to a problem you may be facing today or could well encounter tomorrow. In addition, you’ll find half the book is stocked with new eye-opening solutions to such common problems as how to extend Rails, test and deploy your sites, or add a web service to your actions. And each recipe not only lays out a succinct solution, but explains its rationale and the technologies that make it work.

Loaded with the insights of a Rails community leader, members of the Rails core team and other experts, this is the book you’ll want to have at your side as you craft your next project.

What You Need:
Ruby 1.8.7 or above. Rails 3.1 or above

Table of Contents
Part I: Database Recipes
Recipe 1. Create Meaningful Many-to-Many Relationships
Recipe 2. Create Declarative Named Queries
Recipe 3. Connect to Multiple Databases
Recipe 4. Set Default Criteria for Model Operations
Recipe 5. Add Behavior to Active Record Associations
Recipe 6. Create Polymorphic Associations
Recipe 7. Version Your Models
Recipe 8. Perform Calculations on Your Model Data
Recipe 9. Use Active Record Outside of Rails
Recipe 10. Connect to Legacy Databases
Recipe 11. Make Dumb Data Smart with composed_of()
Recipe 12. DRY Up Your YAML Database Configuration File
Recipe 13. Use Models Safely in Migrations
Recipe 14. Create Self-referential Many-to-Many Relationships
Recipe 15. Protect Your Data from Accidental Mass Update
Recipe 16. Create a Custom Model Validator
Recipe 17. Nest has_many :through Relationships
Recipe 18. Keep Your Application in Sync with Your Database Schema
Recipe 19. Seed Your Database with Starting Data
Recipe 20. Use Helpers in Models
Recipe 21. Avoid Dangling Database Dependencies

Part II: Controller Recipes
Recipe 22. Create Nested Resources
Recipe 23. Create a Custom Action in a REST Controller
Recipe 24. Create a Helper Method to Use in Both Controllers and Views
Recipe 25. Trim Your REST Resources
Recipe 26. Constrain Routes by Subdomain (and Other Conditions)
Recipe 27. Add Web Services to Your Actions
Recipe 28. Write Macros
Recipe 29. Manage a Static HTML Site with Rails
Recipe 30. Syndicate Your Site with RSS
Recipe 31. Set Your Application’s Home Page

Part III: User Interface Recipes
Recipe 32. Create a Custom Form Builder
Recipe 33. Pluralize Words on the Fly (or Not)
Recipe 34. Insert Action-Specific Content in a Layout
Recipe 35. Add Unobtrusive Ajax with jQuery
Recipe 36. Create One Form for Many Models
Recipe 37. Cache Local Data with HTML5 Data Attributes

Part IV: Testing Recipes
Recipe 38. Automate Tests for Your Models
Recipe 39. Test Your Controllers
Recipe 40. Test Your Helpers
Recipe 41. Test Your Outgoing Mailers
Recipe 42. Test Across Multiple Controllers
Recipe 43. Focus Your Tests with Mocking and Stubbing
Recipe 44. Extract Test Fixtures from Live Data
Recipe 45. Create Dynamic Test Fixtures
Recipe 46. Measure and Improve Your Test Coverage
Recipe 47. Create Test Data with Factories

Part V: Email Recipes
Recipe 48. Send Gracefully Degrading Rich-Content Emails
Recipe 49. Send Email with Attachments
Recipe 50. Test Incoming Email

Part VI: Big-Picture Recipes
Recipe 51. Roll Your Own Authentication
Recipe 52. Protect Your Application with Basic HTTP Authentication
Recipe 53. Authorize Users with Roles
Recipe 54. Force Your Users to Access Site Functions with SSL
Recipe 55. Create Secret URLs
Recipe 56. Use Rails Without a Database
Recipe 57. Create Your Own Ruby Gem
Recipe 58. Use Bundler Groups to Manage Per-Environment Dependencies
Recipe 59. Package Rake Tasks for Reuse with a Gem
Recipe 60. Explore Your Rails Application with the Console
Recipe 61. Automate Work with Your Own Rake Tasks
Recipe 62. Generate Documentation for Your Application
Recipe 63. Render Application Data as Comma-Separated Values
Recipe 64. Debug and Explore Your Application with the ruby-debug Gem
Recipe 65. Render Complex Documents as PDFs

Part VII: Extending Rails
Recipe 66. Support Additional Content Types with a Custom Renderer
Recipe 67. Accept Additional Content Types with a Custom Parameter Parser
Recipe 68. Templatize Your Generated Rails Applications
Recipe 69. Automate Recurring Code Patterns with Custom Generators
Recipe 70. Create a Mountable Application as a Rails Engine Plugin

Book Details

  • Paperback: 296 pages
  • Publisher: Pragmatic Bookshelf; 2nd Edition (March 2012)
  • Language: English
  • ISBN-10: 1934356778
  • ISBN-13: 978-1934356777
Download [5.0 MiB]

You may also like...

Leave a Reply