我对如何构建我的路线感到困惑。与时间表我的应用程序处理,并包含三种型号:如何构建Rest API的路线
Employer
Employer id
Name and password
Employee
id
Employer id (FK)
Name and password
Timesheet
Employee id (FK)
Employer id(FK)
Timestamp
我想根据员工ID来选择员工的时间表,并能够选择时间表为所有员工的工作使用给定的雇主雇主ID。在这两种情况下,我还希望能够将我选择的时间表限制在特定的一周。
这是我到目前为止有:
scope '/api' do
scope '/v1' do
scope '/employees' do
get '/' => 'api_employees#index'
post '/' => 'api_employees#create'
scope '/:id' do
get '/' => 'api_employees#show'
put '/' => 'api_employees#update'
scope '/timesheets' do
get '/' => 'api_timesheets#index'
post '/' => 'api_timesheets#create'
scope '/:date' do
get '/' => 'api_timesheets#show'
put '/' => 'api_timesheets#update'
end
end
end
end
end
end
我很困惑我是否应该叫“老板”有在它的员工和时间表整个新的领域,或者我应该把我现有的范围在雇主范围内,以避免重复。