Ruby On Rails and Routes file structure -


i wondering if following acceptable structure routes in route file. have not seen example of being done way, seem logical. if not please let me know why.

rails.application.routes.draw ### begin /some_base_route/    namespace :some_base_route ### begin /some_base_route/lead_vendor  namespace :lead_vendor   'import'   'results' end ### end /some_base_route/lead_vendor   ### begin /some_base_route/sales/    namespace :sales   'view_lead'   'edit_lead'   post 'edit_lead'   'create_contact_log'   'login'   'dashboard' end ### end /some_base_route/sales/   ### begin /some_base_route/admin/  namespace :admin   'admin/login'   'admin/dashboard' end ### end /some_base_route/admin/   ### begin /some_base_route/process/ namespace :process   ### begin /some_base_route/process/sales      namespace :sales     ### begin /some_base_route/process/sales/leads     namespace :leads          'create'       'edit'       'delete'       'call_log_create'     end      ### end /some_base_route/process/sales/leads   end   ### end /some_base_route/process/sales    ### begin /some_base_route/process/new_client   namespace :new_client              'new_client/step1'     'new_client/step2'     'new_client/step3'     'new_client/step4'     'new_client/step5'     'new_client/step6'   end   ### end /some_base_route/process/new_client    ### begin /some_base_route/process/admin/   namespace :admin     ### begin /some_base_route/process/admin/user_management/     namespace :user_management       'create'       'edit'       'delete'       'disable'     end     ### end /some_base_route/process/admin/user_management/      ### begin /some_base_route/process/admin/services/     namespace :services       'create'       'edit'       'delete'     end     ### end /some_base_route/process/admin/services/   end   ### end /some_base_route/process/admin/ end ### end /some_base_route/process/ end ### end /some_base_route/  

@arieshaw right. if rake routes works 'acceptable'.

however, creating routes mean missing out on of magic rails gives you. in particular, you'll need create custom controller actions.

for example, sales area:

namespace :sales   'view_lead'   'edit_lead'   post 'edit_lead'   'create_contact_log'   'login'   'dashboard' end 

i'd refactor , create lead , contactlog objects (perhaps within sales namespace module). i'd use:

namespace :sales   resources :leads   resources :contact_logs, only: [:create, :new]  end 

that give you:

get sales/leads -  index view of leads (probably equivalent dashboard view) sales/leads/new - form new lead post sales/leads - create new lead sales/leads/:id  - view 1 lead sales/leads/:id/edit - edit lead patch sales/leads/:id - update lead delete sales/leads/:id - delete lead sales/contact_logs/new - form new contract log post sales/contact_logs - create contract log 

and actions match index, new, create, edit, update, show, , destroy methods on leadscontroller , contactlogscontroller controllers.

i'd not handle login within sales namespace, rather using gem such devise.

for more information, have @ this: http://guides.rubyonrails.org/routing.html

in summary: doing in example not wrong, , if being asked create specific paths, may fine way of doing it. however, making work little harder may need be, not using of rails restful routes.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -