difference between scope and namespace of ruby-on-rails 3 routing

后端 未结 5 765
离开以前
离开以前 2020-12-07 08:11

I can\'t understand what the difference is between a namespace and a scope in the routing of ruby-on-rails 3.

Could someone please explain?

namespace         


        
5条回答
  •  半阙折子戏
    2020-12-07 08:51

    from the rails guide

    "The namespace scope will automatically add :as as well as :module and :path prefixes."

    so

    namespace "admin" do
      resources :contexts
    end
    

    is the same as

    scope "/admin", as: "admin", module: "admin" do
      resources :contexts
    end
    

提交回复
热议问题