1. Trang chủ
  2. » Giáo án - Bài giảng

the rails way, addison-wesley (2008)

910 278 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 910
Dung lượng 3,09 MB

Nội dung

[...]... Letting the Web Server Send Files 55 Conclusion 56 References 56 Chapter 3 Routing 57 The Two Purposes of Routing 58 Bound Parameters 60 Wildcard Components (“Receptors”) 61 Static Strings 62 The routes.rb File 63 The Default Route 65 Spotlight on the :id Field 66 Default Route Generation 67 Modifying the Default Route 68 The Ante-Default Route and respond_to 69 respond_to and the HTTP-Accept Header 70 The. .. References 88 Chapter 4 REST, Resources, and Rails 89 REST in a Rather Small Nutshell 89 REST in Rails 91 Routing and CRUD 92 Resources and Representations 93 REST Resources and Rails 93 From Named Routes to REST Support 94 Reenter the HTTP Verb 96 The Standard RESTful Controller Actions 96 The PUT and DELETE Cheat 98 Singular and Plural RESTful Routes 98 The Special Pairs: new/create and edit/update... Your Own Helpers 407 Small Optimizations: The Title Helper 407 Encapsulating View Logic: The photo_for Helper 408 Smart View: The breadcrumbs Helper 409 Wrapping and Generalizing Partials 410 A tiles Helper 410 Explanation of the Tiles Partial Code 411 Calling the Tiles Partial Code 412 Write the Helper Method 413 Generalizing Partials 414 Lambda: the Ultimate 414 The New Tiled Helper Method 415 Conclusion... Plugin for Rails 478 Tracking Active Sessions 479 Enhanced Session Security 480 Cleaning Up Old Sessions 481 Cookies 481 Reading and Writing Cookies 482 Conclusion 483 References 483 Chapter 14 Login and Authentication Acts as Authenticated 486 Installation and Setup 486 The User Model 487 Non-Database Attributes 490 Validations 492 The before_save Callback 493 The authenticate Method 494 The remember_token... Reloading 15 The Rails Class Loader 15 Test Mode 17 Production Mode 17 Logging 18 Rails Log Files 20 7 1 Contents xiii Log File Analysis Syslog 24 Conclusion 25 References 25 Chapter 2 22 Working with Controllers The Dispatcher: Where It All Begins 28 Request Handling 28 Getting Intimate with the Dispatcher 29 Render unto View… 31 When in Doubt, Render 32 Explicit Rendering 33 Rendering Another Action’s... Conclusion 125 Reference 126 Chapter 5 Reflecting on Rails Routing 127 Examining Routes in the Application Console 127 Dumping Routes 128 Anatomy of a Route Object 129 Recognition and Generation in the Console 132 Named Routes in the Console 134 Testing Routes 135 The Routing Navigator Plugin 136 Conclusion 137 References 137 Chapter 6 Working with ActiveRecord The Basics 140 Migrations 142 Creating Migrations... delete_all 205 destroy_all 206 length 206 replace(other_array) 206 size 206 sum(column, *options) 206 uniq 207 The belongs_to Association 207 Reloading the Association 208 Building and Creating Related Objects via the Association belongs_to Options 209 :class_name 209 :conditions 210 :foreign_key 213 :counter_cache 213 :include 214 :polymorphic => true 214 The has_many Association 215 has_many Options 216... Inheritance to the Database 286 STI Considerations 288 STI and Associations 288 Abstract Base Model Classes 291 Polymorphic has_many Relationships 292 In the Case of Models with Comments 293 The Interface 293 The Database Columns 294 Has_many :through and Polymorphics 295 Considerations about has_many 296 Modules for Reusing Common Behavior 296 A Review of Class Scope and Contexts 299 The included Callback... Specifying RESTful Controllers Explicitly 105 All Together Now 105 Considerations 107 Deep Nesting? 108 RESTful Route Customizations 110 Extra Member Routes 110 Extra Collection Routes 111 Considerations 112 Controller-Only Resources 113 Different Representations of Resources 115 xvi Contents The respond_to Method 116 Formatted Named Routes 117 The RESTful Rails Action Set 117 Index 118 Show 121 Destroy...xii Contents Contents Chapter 1 Rails Environments and Configuration Startup 2 Default Environment Settings 2 Mode Override 2 Rails Gem Version 2 Bootstrapping 3 RubyGems 5 Initializer 6 Default Load Paths 6 Rails, Modules, and Auto-Loading Code Builtin Rails Info 8 Configuration 9 Skipping Frameworks 9 Additional Load Paths 10 Log-Level Override .

Ngày đăng: 29/04/2014, 14:44

w