Skip to content

Commit

Permalink
ActionPack finished.
Browse files Browse the repository at this point in the history
  • Loading branch information
CFC committed Jun 25, 2008
1 parent a8d315a commit f31fbe6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions text/04_ActionPack/05_atom_feed.markdown
@@ -1,8 +1,8 @@
## Atom Feed 中新的 namespaces

你知道 **atom\_feed** 方法吗?这是 Rails 2.0的一个新特性,使创建 Atom feeds 变得更容易。看一个使用方法
你知道**atom\_feed**方法嗎?這是Rails 2.0的一個新特性,使得建立Atom feeds變得更容易。來看看怎樣操作

在一个 *index.atom.builder* 文件中
在一個*index.atom.builder*檔案中

atom_feed do |feed|
feed.title("Nome do Jogo")
Expand All @@ -20,18 +20,18 @@
end
end

什么是一个 Atom feed? Atom 的名字是基于 XML 样式的 meta 数据。 在互联网中它是一个发布经常更新的内容的协议,如Blog。例如,Feeds 经常以 XML 或 Atom 的格式发布标示为 application/atom+xml 类型.
Atom feed是什麼?Atom的名字是根據XML的樣式與meta資料。在網路中它是一個發佈經常更新內容的協議,如:Blog、新聞。Feeds經常以XML或Atom的格式發佈標示為applicaton/atom+xml類型。

在 Rails 2.0的第一个版本中,该方法允许 **:language**, **:root_url****:url** 参数,你可以从 Rails 文档中获得更多关于这些方法的信息。但基于这一个更新,我们可以包含新的命名空间在一个Feed的root元素中,例如:
在Rails 2.0的第一個版本中,該方法允許**:language****:root_url****:url**參數,你可以從Rails文件中獲得更多關於這些方法的訊息。但是這次的更新我們更可以包含新的namespace在一個Feed的root元素中,例如:

atom_feed('xmlns:app' => 'http://www.w3.org/2007/app') do |feed|

将返回
將返回

<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom"
xmlns:app="http://www.w3.org/2007/app">

修改这个示例之前,我们这样使用它
修改這個之前的範例,我們可以這樣寫

atom_feed({'xmlns:app' => 'http://www.w3.org/2007/app',
'xmlns:openSearch' => 'http://a9.com/-/spec/opensearch/1.1/'}) do |feed|
Expand Down
14 changes: 7 additions & 7 deletions text/04_ActionPack/06_cache.markdown
@@ -1,12 +1,12 @@
## Cache

现在所有的 **fragment\_cache\_key** 方法默认返回 'view/' 前缀命名
現在所有的**fragment\_cache\_key**方法預設回傳'view/'前綴

所有缓存储存已经从 **ActionController::Caching::Fragments::** 删除,并替换为 **ActiveSupport::Cache::**. 在这种情况下,如果你指定一个储存地址,象 **ActionController::Caching::Fragments::MemoryStore** , 你需要这样写: **ActiveSupport::Cache::MemoryStore**.
所有快取儲存已經從**ActionController::Caching::Fragments::**刪除,並替換為**ActiveSupport::Cache::**。在這種情況下,如果你指定一個儲存位置,像**ActionController::Caching::Fragments::MemoryStore**,你需要這樣寫:**ActiveSupport::Cache::MemoryStore**

**ActionController::Base.fragment\_cache\_store** 已经不再使用**ActionController::Base.cache\_store** 取代了它的位置。
**ActionController::Base.fragment\_cache\_store**已經不再使用**ActionController::Base.cache\_store**取代了它的位置。

由于这个新的 **ActiveSupport::Cache::*** 库,它使在 **ActiveRecord::Base** 中的 **cache\_key** 方法容易缓存一个 Active Records ,它这样工作
由於這個新的**ActiveSupport::Cache::**函式庫使得**ActiveRecord::Base**中的**cache\_key**方法容易快取一個Active Records,它是這樣運作的

>> Product.new.cache_key
=> "products/new"
Expand All @@ -17,17 +17,17 @@
>> Person.find(5).cache_key
=> "people/5-20071224150000"

它包含了 **ActiveSupport::Gzip.decompress/compress** 使得用 **Zlib** 压缩更容易。
它包含了**ActiveSupport::Gzip.decompress/compress**使得用**Zlib**壓縮更加容易。

现在你可以在 environment 选项中使用 **config.cache\_store** 指定一个默认的缓存地址。有价值提起的是,如果 **tmp/cache** 目录存在,默认的缓存地址是 **FileStore**, 否则使用 **MemoryStore**. 你可以用以下的方式配置它
現在你可以在environment選項中使用**config.cache\_store**,指定一個預設的暫存位置。有價值提起的是,如果**tmp/cache**目錄存在,預設的暫存位置是**FileStore**,否則使用**MemoryStore**。你可以用下面的方式設定它

config.cache_store = :memory_store
config.cache_store = :file_store, "/path/to/cache/directory"
config.cache_store = :drb_store, "druby://localhost:9192"
config.cache_store = :mem_cache_store, "localhost"
config.cache_store = MyOwnStore.new("parameter")

为了把事情变得更容易,它在 *environments/production.rb* 文件中包含了以下注释,为了提醒你记得这个选项
為了把事情變得更容易,在*environments/production.rb*檔案中包含了以下註解,提醒你記得這個選項

# Use a different cache store in production
# config.cache_store = :mem_cache_store
8 changes: 4 additions & 4 deletions text/04_ActionPack/17_testing_helpers.markdown
@@ -1,8 +1,8 @@
## 简单的 Testing Helpers
## 簡單的Testing Helpers

Rails 早期版本的确 **helpers** 是一个非常烦人的事。我早已经非常痛苦的保证 100% 覆盖,创建 tests 为一些 **helpers**.
在早期最最最令人討厭的事情就是在Rails中測試**helpers**。我已經遭受到很多次100%的覆蓋,建立一些給**helpers**用的測試。

由于 **ActionView::TestCase** 类,在 Rails 2.1中这变得简单得多了。看个示例
透過**ActionView::TestCase**類別,在Rails 2.1中這變得簡單多了。看個範例

module PeopleHelper
def title(text)
Expand All @@ -14,7 +14,7 @@ Rails 早期版本的确 **helpers** 是一个非常烦人的事。我早已经
end
end

现在看我们在 Rails2.1中怎样做同样的事
現在看我們在Rails 2.1中怎樣做同樣的事情

class PeopleHelperTest < ActionView::TestCase
def setup
Expand Down

0 comments on commit f31fbe6

Please sign in to comment.