“Foy is a gifted writer and his descriptions of the philosophies that( impacted the design and implementation of Merb are definitely useful to( everyone affected by the changes in Rails 3.”

—Obie Fernandez, Series Editor


The Expert Guide to Building Merb Applications


Thousands of Ruby and Rails developers are discovering the extraordinary scalability, agility, flexibility, and performance offered by the new Merb MVC framework. The...

See more details below
The Merb Way

Available on NOOK devices and apps  
  • NOOK Devices
  • Samsung Galaxy Tab 4 NOOK 7.0
  • Samsung Galaxy Tab 4 NOOK 10.1
  • NOOK HD Tablet
  • NOOK HD+ Tablet
  • NOOK eReaders
  • NOOK Color
  • NOOK Tablet
  • Tablet/Phone
  • NOOK for Windows 8 Tablet
  • NOOK for iOS
  • NOOK for Android
  • NOOK Kids for iPad
  • PC/Mac
  • NOOK for Windows 8
  • NOOK for PC
  • NOOK for Mac

Want a NOOK? Explore Now

NOOK Book (eBook)
BN.com price
(Save 43%)$31.99 List Price


“Foy is a gifted writer and his descriptions of the philosophies that( impacted the design and implementation of Merb are definitely useful to( everyone affected by the changes in Rails 3.”

—Obie Fernandez, Series Editor


The Expert Guide to Building Merb Applications


Thousands of Ruby and Rails developers are discovering the extraordinary scalability, agility, flexibility, and performance offered by the new Merb MVC framework. The Merb Way is the first comprehensive guide to using, extending, and deploying Merb. Like the bestseller The Rails Way (Addison-Wesley, 2008), this book can either be read cover-to-cover as a tutorial or used for modular coverage that makes it an ideal task reference. Foy Savas systematically covers everything developers need to know to build production-quality Merb applications, offering detailed code examples for jumpstarting virtually any project.


Savas is not only involved in the Merb project as an open source contributor: He uses Merb every day as a professional developer. Drawing on his extensive practical expertise, he delves deeply into the Merb framework’s architecture and source code, revealing its elegance and offering powerful best practices for using it. To maximize this book’s practical value, he also covers the tools most widely used alongside Merb, including the DataMapper ORM, the RSpec tester (and associated behavior-driven development techniques), and several leading Merb plugins.


The Merb Way will help you

  • Master Merb innovations that will be incorporated into Rails 3
  • Understand the fundamentals of Merb development, one step at a time
  • Use Merb’s sophisticated application router to guide incoming requests
  • Explore the Merb stack, master its configuration options, and dive into its internals
  • Use Merb controllers to integrate application code, handle responses, and manage sessions, filters, and exceptions
  • Build templates with both ERB (Erubis) and HAML
  • Use the DataMapper ORM to represent object properties and behaviors
  • Learn best practices for RESTful development with Merb
  • Leverage Helpers to simplify many common development tasks
  • Refactor code, encapsulate it in gems, and share it across multiple applications
  • Customize the responses your application sends to each user
  • Gain a deep, practical understanding of Merb plugins and extensibility
  • Authenticate users with Merb’s modular authentication plugin
  • Configure, generate, describe, and test Merb mailers
  • Use the merb-parts gem to create component-like regions on Web pages
  • Cache content to relieve stress on Web servers
  • Make the most of Behavior Driven Development and testing with RSpec
Read More Show Less

Product Details

  • ISBN-13: 9780321657336
  • Publisher: Pearson Education
  • Publication date: 7/8/2009
  • Series: Addison-Wesley Professional Ruby Series
  • Sold by: Barnes & Noble
  • Format: eBook
  • Edition number: 1
  • Pages: 384
  • File size: 16 MB
  • Note: This product may take a few minutes to download.

Meet the Author

Foy Savas is both a contributor to the Merb project and one of Merb’s earliest adopters. He has applied the Merb framework in both large and small production applications. Foy is director at Assembly (http://assemb.ly), a Boston-based consulting firm focused on connecting brilliant people with innovative ideas. In the past he has served as CTO for a large health and fitness site and as a lead consultant for several white-labeled Web applications.

Read More Show Less

Table of Contents

Foreword xix

Acknowledgments xxi

Merb pastie xxiii

Introduction xxvii

About the author xxxi


Chapter 1: Fundamentals 1

1.1 Generating a new application 1

1.2 The layout of a Merb application 2

1.3 Interactive Merb 9

1.4 Merb configuration 12

1.5 Understanding the Merb stack 20

1.6 An overview of Merb internals 27

1.7 Conclusion 35


Chapter 2: Routing 37

2.1 How Merb routing works 38

2.2 Router configuration 43

2.3 Checking routes 45

2.4 Match rules 50

2.5 Registering routes 54

2.6 Other route settings 57

2.7 Resource routes 60

2.8 Conclusion 64


Chapter 3: Controllers 65

3.1 From request to controller 65

3.2 The controller classes 68

3.3 Custom controller classes 75

3.4 Filters 79

3.5 Redirects 84

3.6 Exceptions 87

3.7 Rendering templates 89

3.8 run_later 97

3.9 Sending and streaming 97

3.10 Conclusion 99


Chapter 4: Views 101

4.1 ERB 101

4.2 Haml 105

4.3 Merb view templates 109

4.4 Partials 111

4.5 Conclusion 112


Chapter 5: Models 113

5.1 Configuration 113

5.2 Model classes 115

5.3 Properties 118

5.4 Associations 132

5.5 CRUD basics 140

5.6 Hooks 154

5.7 Plugins 155

5.8 Conclusion 165


Chapter 6: Helpers 167

6.1 Truncate helper 167

6.2 Numeric helpers 168

6.3 Date and time helpers 171

6.4 Cycle helper 176

6.5 Tag helpers 177

6.6 Form helpers 179

6.7 Conclusion 192


Chapter 7: Slices 193

7.1 Slice development 193

7.2 Slice usage 201

7.3 Conclusion 203


Chapter 8: Sessions 205

8.1 How sessions work 205

8.2 Configuration 206

8.3 Storing sessions 207

8.4 Request access 219

8.5 Controller access 220

8.6 Conclusion 220


Chapter 9: Authentication 221

9.1 Auth core 221

9.2 Auth more 237

9.3 Auth password slices 245

9.4 Conclusion 251


Chapter 10: Mailers 253

10.1 Configuration 253

10.2 Using mailers directly 255

10.3 Mail controllers 257

10.4 Testing 261

10.5 Generation 261

10.6 Conclusion 262


Chapter 11: Parts 263

11.1 Parts controllers 263

11.2 Invoking actions 266

11.3 Generation 267

11.4 Conclusion 267


Chapter 12: Caching 269

12.1 Configuration 269

12.2 Caching basics 271

12.3 Caching helpers 274

12.4 Conclusion 278


Chapter 13: Testing 279

13.1 Rake tasks 279

13.2 Spec files 282

13.3 Model specs 283

13.4 Request specs 285

13.5 Request helper 289

13.6 Request matchers 290

13.7 RSpec extensions 292

13.8 Miscellaneous extensions 294

13.9 Conclusion 295


Afterword 297

Index 299

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)