"Remon van Vliet" <re***@exmachin a.nl> wrote in message
news:44******** *************** @news.xs4all.nl ...
"John A. Bailo" <ja*****@texeme .com> wrote in message
news:y6******** *************** *******@speakea sy.net...
http://media.rubyonrails.org/present...itofbeauty.pdf
[...]
This
[the fact that you can easily predict what it actually does] doesnt apply to the later examples for me though.
I even had trouble with the early examples.
<example>
class Account < ActiveRecord::B ase
validates_prese nce_of :subdomain, :name, :email_address, :password
validates_uniqu eness_of :subdomain
validates_accep tance_of :terms_of_servi ce, :on => :create
validates_confi rmation_of :password, :email_address, :on => :create
end
</example>
Okay, so as a human with an understanding of the semantics of the chosen
names, it looks to me like these validates_foo things describes the account.
The :foo stuff looks like it describes the validate_foo things coming right
before it. For example, ":password" is what ":validates_con firmation_of"
actually validates the confirmation of. and ":on => :create" is when the
validation occurs (upon creation of the account, is my interpretation) .
But then...
<example>
class Project < ActiveRecord::B ase
belongs_to :portfolio
has_one :project_manage r, :class_name => "Person"
has_many :milestones, :dependent => true
has_and_belongs _to_many :categories, :join_table "categorization "
</example>
Does ':class_name => "Person"' modify has_one? Or does it modify
:project_manage r? If we're going for consistency, then this says to me that
the "class_name " of "has_one" is "Person". If we're going for common sense,
the programmer probably meant to say that project managers are people.
So is this an error in the code? Or is this correct Ruby code? I have no
idea.
<quote>
You can recognize truth by
its beauty and simplicity.
When you get it right, it is
obvious that it is right.
Richard Feynman, Scientist
</quote>
This wasn't at all obvious to me. What was also amusing to me was that
immediately after that quote, the first example given was:
<example>
Account.transac tion(david, mary) do
david.withdrawa l(100)
mary.deposit(10 0)
end
</example>
and this is a textbook example of how NOT to do a bank account transaction
system (threading issues, lack of check for sufficient funds, etc.).
- Oliver