建立一個典型的Ruby On Rails網站(四)

來源:互聯網
上載者:User

緩衝和頁面顯示,這是最後一個部分了,真沒想到一個連載竟然用了幾個小時。累了...

外部連結和跟蹤

如果想對外部網站資源進行連結和跟蹤,可以使用如下的helper方法:

Ruby代碼

  external_link_to(text,url)  external_link_to(image_tag(image),url)

這兩種產生連結的方法(一種是文字連結,一種是圖形連結)都可以對連結情況進行日誌記錄。如果將environment.rb檔案中的$USE_EXTERNAL_LINK_POPUPS 參數設定為真,外連結將一彈出框形式存在。下面的參數可以傳遞給Url

Ruby代碼

  :new_window=>true or false -- determines if link appears in new browser window (defaults to true)  :show_only_if_link=>true or false -- determines if image or text is shown if no URL was supplied (defaults to false)  :show_link_icon=>true or false -- determines if the external icon image is shown after the link (defaults to true for text links and false for image links)

對於圖形,可以傳遞如下參數:

Ruby代碼

  :alt=>'value' -- alt tag is set with the value passed  :title=>'value' -- title tag is set with the value passed

對於當前來說,還沒有提供對外部連結跟蹤情況的報表。所有的連結跟蹤情況通過 "external_link_logs" 資料庫進行儲存。

部分緩衝機制

部分緩衝功能需要設定檔設定,才能啟用(config/production.rb)並且要開啟儲存機制

如下:

Ruby代碼

     config.cache_store = :mem_cache_store, '10.0.0.1:11211', '10.0.0.2:11211'

緩衝設定如下:

Ruby代碼

 config.action_controller.perform_caching = true

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.