作者B1ack3y3 (B1ack3y3)
看板Ruby
标题[问题] RoR Tutorial 3中Ch7范例的一个问题
时间Mon Sep 5 19:17:59 2011
最近在学Ruby on Rails. 挑了Ruby On Rails Tutorial 3作为我的入门书
在本书中的Ch7的Listing 7.2的程式码有点疑惑, 我打在下面
Listing 7.2 Validations for the password attribute.
app/models/user.rb
class User < ActiveRecord::Base
attr_accessor :password
attr_accessible :name, :email, :password, :password_confirmation
# Automatically create the virtual attribute 'password_confirmation'.
validates :password, :presence => true,
:confirmation => true,
:length => { :within => 6..40 }
end
我的问题是..在attr_accessible中的 :password_confirmation与
下列那注解里面所提到的password_confirmation是同一个东西吗?
书本里面提到:
we will not introduce a password_confirmation attribute, not even a virtual
one. Instead, we will use the special validation:
validate :password, :confirmation => true
which will automatically create a virtual attribute called
"password_confirmation"..(以下略
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 111.240.169.84