دسترسی نامحدود
برای کاربرانی که ثبت نام کرده اند
برای ارتباط با ما می توانید از طریق شماره موبایل زیر از طریق تماس و پیامک با ما در ارتباط باشید
در صورت عدم پاسخ گویی از طریق پیامک با پشتیبان در ارتباط باشید
برای کاربرانی که ثبت نام کرده اند
درصورت عدم همخوانی توضیحات با کتاب
از ساعت 7 صبح تا 10 شب
ویرایش: [1 ed.] نویسندگان: Simon St. Laurent, Edd Dumbill سری: ISBN (شابک) : 0596518773, 9780596518776 ناشر: O'Reilly Media سال نشر: 2008 تعداد صفحات: 377 زبان: English فرمت فایل : PDF (درصورت درخواست کاربر به PDF، EPUB یا AZW3 تبدیل می شود) حجم فایل: 6 Mb
در صورت تبدیل فایل کتاب Learning Rails به فرمت های PDF، EPUB، AZW3، MOBI و یا DJVU می توانید به پشتیبان اطلاع دهید تا فایل مورد نظر را تبدیل نمایند.
توجه داشته باشید کتاب ریل های یادگیری نسخه زبان اصلی می باشد و کتاب ترجمه شده به فارسی نمی باشد. وبسایت اینترنشنال لایبرری ارائه دهنده کتاب های زبان اصلی می باشد و هیچ گونه کتاب ترجمه شده یا نوشته شده به فارسی را ارائه نمی دهد.
در حالی که بیشتر کتابهای نوشته شده در مورد Rails به برنامهنویسانی که به دنبال اطلاعات در مورد ساختارهای داده هستند، پاسخ میدهد، Learning Rails توسعهدهندگان وب را هدف قرار میدهد که تجربه برنامهنویسی آنها مستقیماً با وب مرتبط است. این کتاب منحصر به فرد به جای شروع با لایه های داخلی یک برنامه وب Rails - مدل ها و کنترلرها - به توسعه Rails از لایه بیرونی می پردازد: رابط برنامه. شما یاد خواهید گرفت که چگونه با Rails چیزی قابل مشاهده بسازید، قبل از اینکه به مدل های پایگاه داده و کد کنترلرهای دشوارتر برسید. با Learning Rails میتوانید از مبانی طراحی وب که قبلاً میدانید شروع کنید و سپس عمیقتر به Ruby، اشیاء و ساختارهای پایگاه داده بروید. این کتاب به شما کمک می کند:
پس از تکمیل Learning Rails، کار با چارچوب وب Rails راحت خواهید بود و به خوبی در راه تبدیل شدن به یک گورو ریل.
While most books written about Rails cater to programmers looking for information on data structures, Learning Rails targets web developers whose programming experience is tied directly to the Web. Rather than begin with the inner layers of a Rails web application--the models and controllers--this unique book approaches Rails development from the outer layer: the application interface. You'll learn how to create something visible with Rails before reaching the more difficult database models and controller code. With Learning Rails , you can start from the foundations of web design you already know, and then move more deeply into Ruby, objects, and database structures. This book will help you:
Once you complete Learning Rails , you'll be comfortable working with the Rails web framework, and you'll be well on your way to becoming a Rails guru.
Learning Rails, 1st Edition......Page 1
Preface......Page 4
1.1. Getting Started in the Online Cloud: Heroku......Page 11
Figure 1-1. The many components of a Rails installation......Page 12
Figure 1-2. A brand new Rails application development environment, in Heroku......Page 13
Figure 1-4. The Heroku gear menu......Page 14
1.2. Getting Started with Instant Rails......Page 15
Figure 1-7. The Rails Applications dialog, where you can start and stop applications, as well as create new ones......Page 16
Figure 1-9. Selecting your new application before starting it......Page 17
1.3. Getting Started at the Command Line......Page 18
1.3.1. Starting Up Rails......Page 20
1.4. What Server Is That?......Page 22
1.5.2. Answers......Page 23
2.1. Creating Your Own View......Page 24
Example 2-2. The new contents of index.html.erb......Page 26
2.2. What Are All Those Folders?......Page 27
2.3. Adding Some Data......Page 28
Example 2-4. A basic controller that sets some variables......Page 29
Figure 2-3. Resulting document incorporating instance variables from the controller......Page 30
Figure 2-4. Simplified processing path for the Hello World programs......Page 31
2.5. Protecting Your View from the Controller......Page 32
Example 2-8. Escaping instance variables without using the parentheses......Page 33
Example 2-9. Modifying index.html.erb to present the @bonus message as many times as @count specifies......Page 34
2.8.2. Answers......Page 35
Example 3-1. A simple stylesheet for a simple page......Page 36
Example 3-2. The Hello message with a hardcoded stylesheet link......Page 37
3.2.1. Splitting View from Layout......Page 38
Example 3-5. A layout for the Hello view, in app/views/layouts/hello.html.erb......Page 39
Figure 3-3. Applying a layout to a view......Page 40
Figure 3-4. Deciding which layout to use, based on naming conventions......Page 41
Example 3-8. Choosing a layout based on program calculations......Page 42
Example 3-9. index.html.erb with newly added HTML structure for separate inclusion......Page 43
3.3. Setting a Default Page......Page 44
Figure 3-6. Accessing a controller by default, when the URL doesn't specify one......Page 45
3.4.2. Answers......Page 46
4.1. Getting Started, Greeting Guests......Page 47
Example 4-2. A view that lets users see a message and enter their name......Page 48
Example 4-3. Making the sign_in method do something......Page 49
Figure 4-2. A greeting that includes the name that was entered......Page 50
4.2. Application Flow......Page 51
Figure 4-4. How Rails breaks down web applications......Page 52
4.3.1. Connecting to a Database Through a Model......Page 53
Example 4-4. The default migration for the entry model......Page 54
Example 4-5. Using ActiveRecord to save a name......Page 55
Example 4-6. Keeping blanks from turning into permanent objects......Page 56
Example 4-7. A controller that also retrieves data from a model......Page 57
Figure 4-5. The guestbook application, now displaying the names of past visitors......Page 58
4.4. Finding Data with ActiveRecord......Page 59
4.5.2. Answers......Page 62
5.1. A First Look at Scaffolding......Page 63
Figure 5-1. The index page of the newly generated application......Page 64
Figure 5-3. A newly created person......Page 65
5.2. REST and Controller Best Practices......Page 66
5.2.1. Websites and Web Applications......Page 67
5.2.2. Toward a Cleaner Approach......Page 68
5.3. Examining a RESTful Controller......Page 69
Example 5-1. A RESTful controller created as part of Rails scaffolding......Page 70
Figure 5-6. The many paths through a REST-based resource......Page 72
5.3.1. Index: An Overview of Data......Page 73
Example 5-2. The index method shows all the records in HTML or XML......Page 74
Example 5-3. The show method extracts one row of data to display......Page 75
5.3.5. Create: Save Something New......Page 76
Example 5-6. The create method saves an incoming record to the database......Page 77
Example 5-7. The update method changes a record and saves the result......Page 78
Example 5-8. The destroy method removes a Person record......Page 79
5.5.2. Answers......Page 80
6.1. More Than a Name on a Form......Page 81
6.2. Generating HTML Forms with Scaffolding......Page 82
Example 6-2. The new.html.erb file contains basic form functionality......Page 83
Figure 6-1. Basic form generated by Rails scaffolding......Page 86
6.3. Form As a Wrapper......Page 87
6.4. Creating Text Fields and Text Areas......Page 89
6.5. Creating Checkboxes......Page 90
Figure 6-2. Simple radio buttons added to a Rails-based form......Page 92
Example 6-4. Creating a sorted set of linked radio buttons from a hash......Page 93
6.7. Creating Selection Lists......Page 94
Figure 6-4. A selection list created from an array of strings......Page 95
Figure 6-5. Rails default approach of using selection lists for dates and times......Page 96
6.10. Creating Helper Methods......Page 98
Example 6-6. Creating a sorted set of linked radio buttons from a hash......Page 99
6.10.1. Letting Helper Methods Make Choices......Page 100
6.11. Putting the Form Body in a Partial......Page 101
Example 6-12. The _form.html.erb file's contents......Page 102
6.12.1. Quiz......Page 103
6.12.2. Answers......Page 104
7.1. Without Validation......Page 105
Figure 7-1. Entering bad data into a form......Page 106
Figure 7-2. Nonnumeric data converted to zeros in a "successful" creation......Page 107
Example 7-2. The foundation of all Rails models......Page 108
Figure 7-3. Failing a simple validation......Page 109
Example 7-3. Model errors reported in HTML from the view......Page 110
7.4.1. Customizing the Message......Page 111
Figure 7-4. A custom error message sent to the user......Page 112
7.4.2. Limiting Choices......Page 113
7.4.5. Numbers Only......Page 114
7.5.1. Testing for Presence......Page 116
7.6.2. Do It Yourself......Page 117
7.7.1. Quiz......Page 118
7.7.2. Answers......Page 119
8.1.1. File Upload Forms......Page 120
8.1.2. Model and Migration Changes......Page 121
8.1.2.1. A migration for an extension......Page 122
8.1.2.2. Extending a model beyond the database......Page 123
8.1.2.3. Showing it off......Page 125
Figure 8-2. A list of users who might have photos......Page 126
Figure 8-4. Stored photos in the public/photo_store directory......Page 127
Figure 8-5. A record displaying an uploaded photo......Page 128
8.2. Standardizing Your Look with Form Builders......Page 129
Example 8-2. A form builder providing a method more tightly bound to the expectations of the country field......Page 130
8.2.2. Adding Automation......Page 131
8.2.3. Integrating Form Builders and Styles......Page 134
8.3.1. Quiz......Page 137
8.3.2. Answers......Page 138
9.1. Connecting Awards to Students......Page 139
9.1.2. Supporting the Relationship......Page 140
Figure 9-1. A basic awards form, where you can guess student numbers......Page 141
Figure 9-2. An awards form that minimizes guesswork about students......Page 142
9.1.3. Guaranteeing a Relationship......Page 143
Figure 9-4. Enforcing the existence of students for every award......Page 144
9.2.2. Counting Awards for Students......Page 145
Figure 9-6. A students list complete with count of awards......Page 146
9.3. Nesting Awards in Students......Page 147
9.3.2. Changing the Controller......Page 148
Example 9-1. Updating a controller to represent a nested resource......Page 149
Example 9-2. Code for displaying awards before nesting by student......Page 151
Example 9-3. Displaying the awards on a student-by-student basis......Page 152
Figure 9-9. The awards list, when the student doesn't have any awards yet......Page 153
Figure 9-10. Entering a new award for a particular student......Page 154
9.3.4. Connecting the Student Views......Page 155
Figure 9-12. Adding a link from a student to a student's awards......Page 156
9.3.5. Is Nesting Worth It?......Page 157
9.4.1. Creating Tables......Page 158
9.4.2. Connecting the Models......Page 159
9.4.3. Adding to the Controllers......Page 160
9.4.5.1. Establishing navigation......Page 162
Figure 9-14. Navigation links to Students and Courses......Page 163
Figure 9-15. Students list showing course counts......Page 164
9.4.5.3. Enrolling students in courses......Page 165
Example 9-4. A courses.html.erb view for registering and removing students from courses......Page 166
Figure 9-17. Adding courses, the first time around......Page 167
Figure 9-19. A (very brief) course description with a link to the roll call list......Page 168
9.5. What's Missing?......Page 169
9.6.1. Quiz......Page 170
9.6.2. Answers......Page 171
10.1. What Migrations Offer You......Page 172
Example 10-1. An empty migration file, fresh from script/generate......Page 173
10.2.2. Running Migrations Forward and Backward......Page 174
10.3. Inside Migrations......Page 175
10.3.2. Data Types......Page 176
10.3.4. Indexes......Page 178
10.4.1. Quiz......Page 179
10.4.2. Answers......Page 180
11.2. Logging......Page 181
11.3. Working with Rails from the Console......Page 182
11.4. The Ruby Debugger......Page 186
Figure 11-1. Waiting for a response because the debugger kicked in......Page 188
11.5.2. Answers......Page 190
12.1. Test Mode......Page 191
Example 12-1. The students.yml fixture file created by Rails......Page 192
Example 12-3. The generated awards.yml fixture, without much real data......Page 193
Example 12-5. The generated courses.yml fixture, with very little content......Page 194
12.3. Unit Testing......Page 195
Example 12-8. An award model with constraints defined......Page 196
Example 12-9. Testing to ensure that the year constraint behaves as expected......Page 197
Example 12-11. More complicated tests for students, testing validity and whether they can be enrolled in courses......Page 198
12.4. Functional Testing......Page 201
Example 12-12. An almost-functional functional test set generated by Rails for the courses controller......Page 202
12.4.1. Calling Controllers......Page 203
12.4.2. Testing Responses......Page 204
12.4.3. Dealing with Nested Resources......Page 205
Example 12-14. Adding support for a nested resource to functional testing......Page 206
Example 12-15. An integration test that tries adding a student......Page 207
12.6. Beyond the Basics......Page 209
12.7.2. Answers......Page 210
13.1. Getting Into and Out of Cookies......Page 211
Example 13-1. Keeping track of names entered with a cookie......Page 212
Figure 13-2. A simple name form, though now one with a cookie behind it......Page 213
Figure 13-4. The form, with a new name set......Page 214
Figure 13-6. Changing names over the session produces a response......Page 215
Example 13-3. Working with an array stored in the session object......Page 217
Example 13-4. Reporting a set of previous names to the user......Page 218
Figure 13-8. The second iteration, where one previous name has been recorded in the session object......Page 219
Figure 13-9. The third iteration, where two previous names have been recorded in the session object......Page 220
Figure 13-10. Two models for storing data in sessions......Page 221
13.3.1. Quiz......Page 222
13.3.2. Answers......Page 223
14.1. Installation......Page 224
14.3. Controlling Sessions......Page 225
Figure 14-1. Creating a new user in the default form......Page 226
Figure 14-2. Logging in for the first time......Page 227
Example 14-3. The welcome page, in HTML with a few helpers......Page 228
Figure 14-3. A welcome screen when no one is actually logged in......Page 229
Figure 14-5. The welcome screen after creating an account......Page 230
Figure 14-6. Navigation at the top now includes going back to the welcome page or logging out of the application entirely......Page 231
Example 14-4. A migration for adding a boolean administration flag to the users table......Page 232
Figure 14-8. A new user, freshly welcomed......Page 234
Figure 14-10. The editing page also works for the new user......Page 235
Figure 14-11. The new user's attempt to edit a document is finally blocked and they face a new login screen......Page 236
Example 14-5. Removing inappropriate choices from a user with limited powers......Page 237
14.5. More Options......Page 238
14.6.2. Answers......Page 239
15.1.1. Specifying Routes with map.connect......Page 240
15.1.4. Named Routes......Page 243
15.1.6. Regular Expressions and Routing......Page 244
15.1.7. Mapping Resources......Page 245
15.1.8. Nesting Resources......Page 247
15.1.9. Checking the Map......Page 248
15.2.1. Pointing url_for in the Right Direction......Page 249
15.2.2. Adding Options......Page 250
15.4.1. Quiz......Page 251
15.4.2. Answers......Page 252
16.1. Ajax Basics......Page 253
Figure 16-2. Updating only parts of a page with multiple XmlHTTPRequest calls......Page 254
16.2.1. Rails as a Server API......Page 255
16.2.2. Rails and the Client......Page 256
16.3.1. Making the Form More Scriptable......Page 257
Example 16-1. A courses.html.erb file getting ready for some Ajax manipulation......Page 258
Example 16-2. The course_add method, modified to support multiple removals specified by checkboxes......Page 259
Figure 16-3. A revised form for adding and removing courses for a given student......Page 260
16.3.2. Changing Courses without Changing Pages......Page 261
Example 16-3. Adding the necessary JavaScript links to the students.html.erb layout file......Page 262
Example 16-4. An RJS file for updating the display when a course is removed from a student's list......Page 263
Example 16-5. An RJS file for updating the display when a course is added to a student's list......Page 264
Example 16-6. A partial representing a table row......Page 265
16.3.3. Rethinking Logic......Page 266
16.4. Moving Further into Ajax......Page 267
16.5.2. Answers......Page 268
Example 17-1. Options for sending mail, from development.rb......Page 269
Example 17-2. A controller method for sending email......Page 270
Example 17-4. Generating a plain-text report of an award for emailing......Page 271
Figure 17-1. An opportunity to send an email......Page 272
Figure 17-3. The email, received......Page 273
17.2. Sending HTML Mail......Page 274
Example 17-8. An html_certificate method specifying headers and sending content......Page 275
Figure 17-5. An extra option for sending awards email......Page 276
17.3. Sending Complex HTML Email......Page 277
Example 17-10. A model for sending multipart email messages......Page 278
Example 17-11. The certificate.text.html.erb view for generating HTML inside a multipart email message, referencing a graphic through its Content-ID......Page 280
Figure 17-7. A mail message containing a graphic, sent by the fictional School of Rails, whose logo is familiar......Page 281
17.4.1. Setup......Page 282
Example 17-13. Processing incoming emails to see if they came from an administrator, extracting their content with regular expressions, and then making a change to the student data......Page 283
Example 17-14. A test message for trying out Rails ability to process incoming email......Page 284
17.5.2. Answers......Page 285
18.1.1. SQL Injection......Page 286
18.1.2. Cross-Site Scripting......Page 287
18.1.4. URL Hacking......Page 288
18.2.1. Changing to Production Mode......Page 289
Figure 18-1. How most developers run Rails in development mode......Page 290
18.2.2.3. App server choices......Page 291
18.2.3.1. Creating the MySQL database......Page 292
18.2.3.2. Configuring Rails to use the MySQL database......Page 293
18.2.3.3. A quick test......Page 294
18.2.3.4. Installing Phusion Passenger......Page 295
Figure 18-3. A welcome screen from the newly deployed application......Page 298
18.2.4. Deployment Directions......Page 299
18.3.2. Answers......Page 300
19.3. Ruby......Page 301
19.5. Explore Other Ruby Frameworks......Page 302
19.6. Migrating Legacy Applications to Rails......Page 303
19.7. Keep Exploring......Page 304
A.1. How Ruby Works......Page 305
A.2. How Rails Works......Page 306
A.3. Getting Started with Classes and Objects......Page 307
A.5.1. Variables......Page 308
A.5.1.1. Arrays and hashes......Page 309
A.5.2.1. Privacy, please......Page 311
A.5.2.3. Calling methods: advanced options......Page 312
A.6.1. Operators......Page 314
A.6.2. if, else, unless, and elsif......Page 316
A.6.4. case and when......Page 318
A.6.5.1. while and until......Page 319
A.6.5.3. for......Page 320
A.6.6. Many More Possibilities......Page 321
Figure B-1. The classic row–column approach to tables......Page 322
B.1.1. Connecting Tables......Page 324
B.1.2. Using Tables to Connect Tables......Page 325
Figure B-5. Connected tables in a database......Page 326
B.2. Databases, Tables, and Rails......Page 327
C.2. Starting Small......Page 329
C.3. The Simplest Expressions: Literal Strings......Page 330
C.4. Character Classes......Page 331
C.6. Modifiers......Page 332
C.7. Anchors......Page 333
C.8. Sequences, Repetition, Groups, and Choices......Page 335
C.10. More......Page 336
D.1. Calling Helper Methods......Page 338
D.2. ActiveRecordHelper......Page 339
D.3. AssetTagHelper......Page 340
D.4. AtomFeedHelper and AtomFeedHelper::AtomFeedBuilder......Page 341
D.5. BenchmarkHelper, CacheHelper, and CaptureHelper......Page 342
D.6. DateHelper......Page 343
D.8. FormHelper, FormTagHelper, and FormOptionsHelper......Page 344
D.9. JavaScriptHelper......Page 348
D.11. PrototypeHelper......Page 349
D.13. SanitizeHelper......Page 351
D.15. TagHelper......Page 352
D.16. TextHelper......Page 353
D.17. UrlHelper......Page 355
E.1. Speaking in Rails......Page 357
Appendix. Colophon......Page 377