最新のglobalize2とレール2.2を使用しています。私は、次のようなバグや特徴があるのだろうかと思います。データセット内の各アイテムに対して別々のdbクエリーがあるようです。それはすぐに何百ものクエリが発生する可能性があるため、正しいとは言えません。Globalize2(レール)モデルを翻訳する
イラスト。シンプルコントローラ:
:<% @menu_sections.each do |menu_section| %>
<p><%= link_to menu_section.name, :controller => 'store', :action => 'list_menu_items_for_section', :section_id => menu_section.id %></p>
<% end %>
は、DBクエリ内のすべてのmenu_section.name結果のように見える:
def index
@menu_sections = MenuSection.find(:all)
end
その後@menu_sectionsは、ローカライズされた属性(名前が)と呼ばれているビュー、中を通してループされます
Processing StoreController#index (for 10.0.2.2 at 2009-03-02 16:05:53) [GET] Session ID: 468f54928cbdc0b19c03cfbd01d09fa9 Parameters: {"action"=>"index", "controller"=>"store"} MenuSection Load (0.0ms) SELECT * FROM `menu_sections` Rendering template within layouts/store Rendering store/index Rendered application/_js_includes (0.0ms) MenuSection Columns (0.0ms) SHOW FIELDS FROM `menu_sections` MenuSectionTranslation Load (0.0ms) SELECT * FROM `menu_section_translations` WHERE (`menu_section_translations`.menu_section_id = 1 AND (`menu_section_translations`.`locale` IN ('en','root'))) MenuSectionTranslation Columns (0.0ms) SHOW FIELDS FROM `menu_section_translations` MenuSectionTranslation Load (0.0ms) SELECT * FROM `menu_section_translations` WHERE (`menu_section_translations`.menu_section_id = 2 AND (`menu_section_translations`.`locale` IN ('en','root'))) MenuSectionTranslation Load (0.0ms) SELECT * FROM `menu_section_translations` WHERE (`menu_section_translations`.menu_section_id = 3 AND (`menu_section_translations`.`locale` IN ('en','root'))) Completed in 340ms (View: 320, DB: 0) | 200 OK [http://www.dev.babooka.com/store]
あなたはどう思いますか?おそらく、レールにdbデータを変換するためのより良い方法がありますか?