title: Rails routes: Nested, Member, Collection, namespace, scope and customizable
body: <p>I am trying to understand more about Rails routes. </p>
  
  <p><strong>Member and Collection</strong></p>
  
  <pre><code>  # Example resource route with options:
       resources :products do
         member do
           get 'short'
           post 'toggle'
         end
  
         collection do
           get 'sold'
         end
       end
  </code></pre>
  
  <p><strong>Namespace and Scope</strong></p>
  
  <pre><code>  # Example resource route within a namespace:
       namespace :admin do
         resources :products
       end
  
       scope :admin do
         resources :products
       end
  </code></pre>
  
  <p><strong>Constraints, Redirect_to</strong></p>
  
  <pre><code># Example resource route with options:
   get "/questions", to: redirect {|params, req| 
       begin
         id = req.params[:category_id]
         cat = Category.find(id)
         "/abc/#{cat.slug}"
       rescue
         "/questions"
       end
   }
  </code></pre>
  
  <hr>
  
  <p><strong>Customization:</strong></p>
  
  <pre><code>resources :profiles
  </code></pre>
  
  <p>original url from <code>resource profiles</code> for edit.</p>
  
  <pre><code>http://localhost:3000/profiles/1/edit
  </code></pre>
  
  <p>I want to make it for users available only through click <code>edit profile</code> and see url like in below.</p>
  
  <pre><code>http://localhost:3000/profile/edit
  </code></pre>
  
  <hr>
  
  <p>Also, is there advanced routing, How most big companies design their routes in rails ? I would be really glad to see new kind of routes if there exist.</p>
  
  <p>Thank You ! </p>