Mike Clark and the Rails Community

 0  0  291  2019-03-16 01:28:28 Laporkan dokumen yang dilanggar

Part V—Design Recipes 108

Part VI—Asynchronous Recipes 126

Part VII—E-mail Recipes 141

  Shortcuttin’ the Console . Playin’ in the Sandbox .

Part VIII—Console Snacks 156

Part X—Performance and Scalability Recipes 204

Part XI—Security Recipes 226

Part XII—Deployment and Capistrano Recipes 232

  Describing Behaviour from the Outside-In With RSpec . Caching Up With the Big Guys .

Part XIII—Big-Picture Recipes 257

  If you’re reading the PDF version of this book, you can report an error on a page by clicking the “erratum” link at the bottom of the page,and you can get to the source code of an example by clicking the gray lozenge containing the code’s file name that appears before the listing. So in our Active Resource client, we include the login and password as part of the URL pointing to where the resource lives: Note that if we were to use http:// , the encoded login and password will travel across the ’net in plaintext which any hacker worth his salt candecode over lunch, so don’t forget to use https:// !

Mike says. .

  SolutionStudent Say we have a model that validates the presence of a name and that the social security number is of the format ###-##-#### (whereeach pound sign is a number), like this: class Student < ActiveRecord::Basevalidates_presence_of :name validates_format_of :ssn, :with => /^[\d]{3}-[\d]{2}-[\d]{4}$/, :message => "must be of format ###-##-####"end Then imagine we add a new Teacher model and teachers also need to have valid social security numbers. So in the action ProjectsController Project of our we create a object like normal, but we also add three tasks to the project (in memory) so that our form hassomething to work with: Download MultiModelForm/app/controllers/projects_controller.rb def new@project = Project.new 3.times { @project.tasks.build }end The form template is a bit tricky since we need to handle fields for the Project model and each of its Task models.

Dokumen baru
Aktifitas terbaru
Penulis
123dok avatar

Berpartisipasi : 2019-03-13

Dokumen yang terkait
Tags

Timothy Clark Mike Wright Zilia Iskoujina And Philip Garnett

The White Community And Migrant Materi Ajar Psycholinguistics Chapter 3 Clark Clark

Shifts In The Abundance And Community St

Hospital And Community

A Book For The Community By The Community

The Challenges And Opportunities Of Asean Economic Community The Behavior Of The Community

The Interest Of Community

Community Forestry And Poverty

Mike Clark and the Rails Community

Gratis

Feedback