Rails.application.routes.draw do devise_for :users authenticated :user do root 'home#index', as: :authenticated_root end authenticate :user, lambda { |u| u.admin? } do resources :users, only: [:index, :edit, :update, :destroy] end devise_scope :user do root to: 'devise/sessions#new' end resources :participants do resources :onboardings, only: [:index, :create, :update] do collection do post 'submit_onboarding' end end resources :bank_accounts, only: [:index, :new, :create, :edit, :update, :destroy] collection do get 'search' # Define search on the collection, not on a member end member do post 'link_worker' # Other member routes post 'link_vendor' end end resources :workers do resources :onboardings, only: [:index, :create, :update] do collection do post 'submit_onboarding' end end resources :bank_accounts, only: [:index, :new, :create, :edit, :update, :destroy] member do post 'link_participant' post 'link_employer' end get 'search', on: :collection end resources :vendors do resources :onboardings, only: [:index, :create, :update] do collection do post 'submit_onboarding' end end resources :bank_accounts, only: [:index, :new, :create, :edit, :update, :destroy] collection do get 'search' end end resources :employments, only: [:edit, :update, :destroy] resources :employer_records, only: [:edit, :update, :destroy] do post 'link_participant', on: :collection end resources :service_contracts resources :employers do resources :onboardings, only: [:index, :create, :update] do collection do post 'submit_onboarding' end end member do post 'link_worker' end collection do get 'search' end end resources :forms resources :users # Setup the routes under a scope to mimic namespace-like behavior without actual namespacing scope '/admin', controller: :admin do get 'users/new', as: 'new_admin_user', action: :new_user # for displaying the new user form post 'users', as: 'admin_users', action: :create_user # for submitting the new user form # You can add more admin routes here as needed end get 'home/index' # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # Can be used by load balancers and uptime monitors to verify that the app is live. get "up" => "rails/health#show", as: :rails_health_check # Defines the root path route ("/") # root "posts#index" end