<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 路由 * <a name="member-collection-routes"></a> 當需要為一個 RESTful 資源添加動作時(你真的需要嗎?),應使用 `member` 路由和 `collection` 路由。 <sup>[[link](#member-collection-routes)]</sup> ```Ruby # 差 get 'subscriptions/:id/unsubscribe' resources :subscriptions # 好 resources :subscriptions do get 'unsubscribe', on: :member end # 差 get 'photos/search' resources :photos # 好 resources :photos do get 'search', on: :collection end ``` * <a name="many-member-collection-routes"></a> 當需要定義多個 `member/collection` 路由時,應使用塊結構。 <sup>[[link](#many-member-collection-routes)]</sup> ```Ruby resources :subscriptions do member do get 'unsubscribe' # 更多路由 end end resources :photos do collection do get 'search' # 更多路由 end end ``` * <a name="nested-routes"></a> 使用嵌套路由(nested routes),它可以更有效地表現 ActiveRecord 模型之間的關系。 <sup>[[link](#nested-routes)]</sup> ```Ruby class Post < ActiveRecord::Base has_many :comments end class Comments < ActiveRecord::Base belongs_to :post end # routes.rb resources :posts do resources :comments end ``` * <a name="namespaced-routes"></a> 使用命名空間路由來歸類相關的動作。 <sup>[[link](#namespaced-routes)]</sup> ```Ruby namespace :admin do # 將請求 /admin/products/* 交由 Admin::ProductsController 處理 # (app/controllers/admin/products_controller.rb) resources :products end ``` * <a name="no-wild-routes"></a> 不要使用舊式的控制器路由。這種路由會讓控制器的所有動作都通過 GET 請求調用。 <sup>[[link](#no-wild-routes)]</sup> ```Ruby # 非常差 match ':controller(/:action(/:id(.:format)))' ``` * <a name="no-match-routes"></a> 不要使用 `match` 來定義任何路由,除非確實需要將多種請求映射到某個動作,這時可以通過 `via` 選項來指定請求類型,如 `[:get, :post, :patch, :put, :delete]`。 <sup>[[link](#no-match-routes)]</sup>
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看