Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. User `constraints` to specify the subdomain name for api portion and can introduce load balancing or increase number of api server needed based on its usage.
  2.  
  3. ```ruby
  4. Rails.application.routes.draw do
  5. namespace :api, path: '/', constraints: { subdomain: 'api' } do
  6. resources :users
  7. end
  8. end
  9. ```
  10.  
  11. `namespace: api, path: '/'` => the `namespace` by default will put the namespace value in the url (e.g: `localhost:3000/api`), but when specify the `path` is '/', there will be no `/api` in the url.
  12.  
  13. This is good because we can group our codes in `api` folder and can use api subdomain.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement