[RUBY] Differences between namespace, module, scope and as in Rails routing

Overview

I've put together some confusing methods when writing routing.

Each name of the routing

resources :users


Named routing path directory
      ↓                ↓                         ↓

   Prefix Verb   URI Pattern               Controller#Action
    users GET    /users(.:format)          users#index
          POST   /users(.:format)          users#create
 new_user GET    /users/new(.:format)      users#new
edit_user GET    /users/:id/edit(.:format) users#edit
     user GET    /users/:id(.:format)      users#show
          PATCH  /users/:id(.:format)      users#update
          PUT    /users/:id(.:format)      users#update
          DELETE /users/:id(.:format)      users#destroy

Correspondence table of each method

Named routing path directory
namespace
module × ×
scope × ×
as × ×

Aim for a clean routes file!

reference: https://devblast.com/b/rails-5-routes-scope-vs-namespace

Recommended Posts

Differences between namespace, module, scope and as in Rails routing
[Understanding] Differences between hashes and arrays in Ruby
Differences between Ruby syntax error statements in Ruby and binary
Differences between browser sessions and cookies and Rails session and cookies methods
Differences between Fetch Type LAZY and EAGER in Hibernate
Rails: Difference between resources and resources
[Rails] Differences between redirect_to and render methods and how to output render methods
Think about the differences between functions and methods (in Java)
Differences between IndexOutOfBoundsException and ArrayIndexOutOfBoundsException
Differences in how to handle strings between Java and Perl
Differences between "beginner" Java and Kotlin
Enable jQuery and Bootstrap in Rails 6 (Rails 6)
[Rails] Difference between find and find_by
Remove "assets" and "turbolinks" in "Rails6".
CRUD features and MVC in Rails
Differences between Applet class and JApplet class
[Rails] Differences and usage of each_with_index and each.with_index
Differences between Java and .NET Framework
[rails] Difference between redirect_to and render
[Rails] Difference in behavior between delegate and has_many-through in the case of one-to-one-to-many
A note on the differences between interfaces and abstract classes in Java
Difference between final and Immutable in Java
Difference between pop () and peek () in stack
Differences between preface and postfix of operators
[Java] Differences between instance variables and class variables
[rails] How to configure routing in resources
Difference between getText () and getAttribute () in Selenium
Difference between "|| =" and "instance_variable_defined?" In Ruby memoization
Difference between EMPTY_ELEMENTDATA and DEFAULTCAPACITY_EMPTY_ELEMENTDATA in ArrayList
Differences between Ruby strings and symbols [Beginner]
Difference between int and Integer in Java
[Rails] Difference between redirect_to and render [Beginner]
Organize your own differences in writing comfort between Java lambda expressions and Kotlin lambda expressions.