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

后端 未结 5 744
离开以前
离开以前 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:40

    The difference lies in the paths generated.

    The paths are admin_posts_path and admin_comments_path for the namespace, while they are just posts_path and comments_path for the scope.

    You can get the same result as a namespace by passing the :name_prefix option to scope.

提交回复
热议问题