Ruby on Rails Enterprise Application Development::
Plan, Program, Extend
www.PACKTPUB.com  FREE ONLINE EDITION: Read full chapters online, download free samples from the book and more...
Book Contents Index > Chapter 5
Introduction
1: Introduction
2: The Initial Problem
3: Laying the Foundations
4: Working with Rails Free Chapter
5: Building the User Interface
6: Into Production
7: Improving the User Experience
8: Extending the Application
9: Advanced Deployment

10: Down the Track

Appendix A: Running Your Own Gem Server

Index

Latest Updates

Free Chapter:

Chapter 4: Working with Rails [ 1.7 MB PDF]

Code Download

Contact us

Chapter 5: Building the User Interface

In the last chapter, we worked on implementing a solid model layer for the application. While the console and unit tests are a fine way for developers to access the models, they are not a suitable interface for the intended users of the system (Acme administrative staff). This chapter describes how to build a web interface onto the models we have developed, including:

  • A walk-through of creating a controller from scratch
  • How to use views, layouts, and helpers
  • Using pagination
  • Linking views together to create drill-downs
  • Adding style-sheets
  • Writing custom helpers and partials
  • Writing complex controller actions to update multiple models simultaneously
  • Fleshing out the application functionality

By the end of the chapter, we will have a basic, fully-functional web-based CRM application.

Chapter 5: Building the User Interface

  • Controllers and Views: A Recap
  • Creating a Simple Controller and Its Views
    • Views and Layouts
      • Adding a View to the Application
      • Displaying Model Instances in a View
      • Pagination
      • Linking to Another View
      • Adding a Layout
      • Adding a Stylesheet
  • Adding a Controller for Companies
    • Create the CompaniesController
    • Create the Index View
    • Test It!
    • Summary
  • Advanced View Techniques
    • Custom Helpers
      • Default Messages for Empty Fields
      • Date Formatting
    • Showing Associated Records
      • Refining Using a Helper
      • Showing an Address with a Partial
    • Rendering Pagination Links with a Partial
    • Adding a Menu
  • C*UD (Create, Update, Delete)
    • Creating a Person
      • Refining with a Helper
      • Validation Errors
      • The Flash
      • Finishing Touches
    • Updating a Person
    • Opportunities for Refactoring
      • Using Filters
      • Creating Application-Level Controller Methods
    • Deleting a Person
    • Adding Edit and Delete Links to a Person's Profile
  • Editing Multiple Models Simultaneously
    • Adding a New Address for a Person
      • Using Functional Testing for Complex Actions
    • Updating a Person and Their Address
    • Summary
  • Fleshing Out Companies and Addresses
    • Managing Companies
      • Stubbing Out the Navigation
      • A Shared View to Confirm Deletions
      • Attaching a Person to a Company
      • Creating and Updating Companies
    • Managing Addresses
      • Adding a Callback to Company Deletions
      • A Very Quick Interface for Addresses
  • Summary
   

 

Paperback 528 pages
Released: October 2007
ISBN: 1847190855
ISBN 13: 978-1-847190-85-7

     

 




View the book details
on PacktPub.com

 


 

  This website is owned and maintained by Packt Publishing Ltd, 2007. All rights reserved. Terms and Conditions