论坛首页 编程语言技术论坛

Ruby for Rails, 译者的勘误表

浏览 2910 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2006-09-16  
在翻译 Ruby for Rails 一书过程中,发现一些错误和疑问,我把它列在下面,请帮忙看看。

大多数的问题都没有出现在作者提供的勘误表中,所以命名为“译者的勘误表”。
现在实在没有时间把它好好整理,不过,还是可以看得比较清楚的。

原文中的错误:
1.p.87: 算法步骤3,4 , 错误
2.p.82: but in a open-ended way, 含混。Helper method 属于第二类, 然后作者又说它是 open-ended 的, 与他的第三个分类混淆了。
3.p.55: composer 误为 work , 错误
4.p.88: 第一句话, 关于 mnums 的论述有错。与代码不符合。
5. 第2章的列表 2.5 2.6 2.7 的不同标题, 为什么?
5.5:  p.105 shortenging the output of our little program ,应该是shorten the output part of our little program
6.p.212 :or the word “no”, 应该是 or the word “y”。
7.p.212: when statement, 应该 when clause
8.p.227 rescue 块, rescue part 含义混淆。
9. p.341 ,singleton method class 应该是 singleton class
10.p.341, class’ class 应该是 class’ superclass
11. P.354, The first time we call pr, we provide three arguments; 应该是 two arguments
12.p.354, Ruby offers several variations on the callable method-or-function theme, 我认为 callable object 更准确。
13.p.356 The block is just some code that floats in front of the method inside
curly braces (or do/end), waiting to be used. 它是否意味着,block is the code appears at the end of a method call 。
14.p.356 &var 应该是 &block
15.p.361 recipes 错为 pages
16.p.377 composer table 应该是 composers table
17.p.377 what your classes are (composer, edition, and so on) 应该是 Composer,Edition, and so on
18.  p.379 The association directives are class methods of the model classes you create,
which means they’re class methods of ActiveRecord::Base, because they appear
in your classes courtesy of inheriting from that preexisting class.
这段话的逻辑好像有问题。
19. p.382  instrument 和instruments 模型不统一。
20.p.383 track and record
each case of a relationship between an edition and an author. 应该是 between an instrument and an work
21.p.383 ,The table’s role is to record the associations between authors and books. 应该是 between an instrument and an work
22.p.384 work table 应该是 works table
23.p.398,p.397, Which customers have ordered this work?, 前后分类是矛盾的。
24.p.401: This method starts by unconditionally gathering all the works by this composer,
which it does by calling works. At this point, ActiveRecord is finished; the one and
only database query required here returns all the works for this composer. What
remains is pure Ruby: harvesting the editions of the works (courtesy of map) and
massaging the resulting array-of-arrays of editions with flatten and uniq. Each of
these operations creates a new array—potentially a large one, if we’re dealing with
a well-stocked music store.
Works 是一个 database query , editions 也是一个 database query。 错误。
我认为,他这个例子可以这么说: Rails 自动操作时,是低效的,需要使用多个 SQL, 而直接编写 SQL ,可以只用一条 SQL 语句。
25. P.404 In the sections that follow,, 应该是 subsections
26.p.405 : %wf {…} construct 应该是 %w{…}
27. p.405: Because it’s possible that we’ll encounter an instrument
that isn’t on this list, if no index is found we return 0, which in a sorting context
means equal to:
我认为,这里零并不意味着 equal to .


另外:at the top of the model file : 应该是 at the top level of the model file


28. p.408 :here’s double interpolation going on. First, we interpolated the title. Then, we interpolate this entire expression。 这段话有点前言不搭后语。 Double 和 first then , 不是对应的关系。要么你说它是四重的 quadruple. 要么你说它是嵌套的。 Nested.

29.p.411: we will take the former approach here.我认为 former 应该改为 latter.

30.P412: where the array of match criteria is the key and the name
of the period is the key.. 后一个key 应该是 value。

31. p.412: the whole expression returns false or nil. 会有两种可能吗? 我的测试结果是 false。

32. P.415: Going through these one at a time, and never repeating an item (thanks to uniq), rank sorts them by how often they occur in the non-uniqued list. 红色标出部分是什么意思?

33: Ruby for rails 一书是一本好书,不过第15 章 硬模型改进部分写得实在不太好。错误很多啊。

34.p.416: It would be possible to store items in a hash
that kept closer track of ties, but it’s questionable whether the effort to
do this would pay off, 这段话是什么意思?猪。

35:p.416的整段注释,基本上是逻辑含糊,语言晦涩。

36. P.416 this number was stored in the database and incremented when
the customer changed the number of copies of an edition or ordered another
copy.
Incremented 应该是changed。

37.p.421:
def Composer.sales_rankings
r = Hash.new(0)
dd Work.sales_rankings.map do |work,sales|
r[work.composer.id] += sales
end
r
end

代码是否应该为 r[Work.find(work_id).composer.id]

38:勘误表中的这一段是错的/
Page 349:
In the last code snippet, this:
c = C.new
should be:
c = c.new
However, the reuse of the variable c, while legal, is confusing. A clearer version of the last two lines is:
c_instance = c.new c_instance.some_method

40. page 150
"Seeing this inheritance chain, and knowing what you know about classes as the
factories from which objects are created, you can deduce that a controller in Rails is
an object."

I am wondering whether there is a relation between the inheritance chain and the fact that a controller in Rails is an object.

41.page 149
excerpted:
"class ApplicationController < ActionController::Base
This call creates a new class, ApplicationController,, which inherits from the class
ActionController::Base."

Dose this means that keyword "class" can be considered as a method call? No.

42.P.429: That’s pretty much it for helper methods in the music store application. 我认为 it 应该没有
43.p.429: We summon up the partial view at a particular
place in the main or master template with a call to render. 问题: 这个 the 指的是什么?

44.p.431: The decision not(没有not,见勘误表) to do so is semantic or aesthetic:。 我认为勘误表这里似乎也有问题:应该保留 not???

45. p.438: The main welcome view template, shown in listing 16.9,应该是16.7

论坛首页 编程语言技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics