Table of Contents
Acknowledgments ix
Preface xi
1 Creating an Application Layout 1
1.1 Creating a Basic Layout 2
1.2 Setting Up a Boilerplate 6
1.3 Building the Page Frame 14
1.4 Adding a Sidebar 23
1.5 Adding Navigation 28
1.6 Displaying Notifications 36
1.7 Validating Our Code 39
1.8 Testing Internet Explorer 41
1.9 Wrapping Up 47
2 Improving Readability 49
2.1 Choosing a Templating Language 49
2.2 Standardizing Coding Practices 51
2.3 Simplifying Complex Output 56
2.4 Working with Models 63
2.5 Displaying Conditional Content 65
2.6 Adding Model DOM IDs for JavaScript 69
2.7 Cleaning Up 71
2.8 Wrapping Up 72
3 Adding Cascading Style Sheets 73
3.1 Using the Asset Pipeline 73
3.2 Learning SCSS 76
3.3 Adding Sprites 88
3.4 Using Web Fonts 92
3.5 Wrapping Up 98
4 Adding JavaScript 101
4.1 Using JavaScript from Rails 101
4.2 Testing Ajax 110
4.3 Wrapping Up 117
5 Building Maintainable Forms 119
5.1 Using Semantic Form Tags 119
5.2 Building Custom Form Builders 132
5.3 Looking Toward the Future of HTML5 Form Elements 140
5.4 Wrapping Up 142
6 Using Presenters 143
6.1 Presenting a Record 144
6.2 Presenting Multiple Records 153
6.3 Using Presenters for Serialization 158
6.4 Wrapping Up 161
7 Handling Mobile Views 163
7.1 Building a Flexible Layout 164
7.2 The Next Level with Responsive Design (�media queries) 168
7.3 Using Mobile-Specific Templates 174
7.4 Using jQuery Mobile 179
7.5 Wrapping Up 188
8 Working with Email 189
8.1 Building a Mailer 189
8.2 Handling Email Templates 191
8.3 Testing Locally 195
8.4 Testing Across Clients 196
8.5 Wrapping Up 206
9 Optimizing Performance 207
9.1 A/B Testing with Vanity 207
9.2 Performance Testing and Maintenance 214
9.3 Wrapping Up 228
9.4 Where Do We Go from Here? 229
A1 The Rails View Rules 233
A2 Bibliography 235
Index 237