We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a2aced4 commit 9112869Copy full SHA for 9112869
app/resources/employee_resource.rb
@@ -6,4 +6,30 @@ class EmployeeResource < ApplicationResource
6
scope: -> { Position.all },
7
foreign_key: :employee_id,
8
resource: PositionResource
9
+
10
+ def create(attributes)
11
+ employee = Employee.create(attributes)
12
+ log('Created', employee)
13
+ employee
14
+ end
15
16
+ def update(attributes)
17
+ employee = Employee.find(attributes[:id])
18
+ employee.update_attributes(attributes.except(:id))
19
+ log('Updated', employee)
20
21
22
23
+ def destroy(id)
24
+ employee = Employee.find(id)
25
+ employee.destroy
26
+ log('Deleted', employee)
27
28
29
30
+ private
31
32
+ def log(prefix, employee)
33
+ Rails.logger.info "#{prefix} #{employee.first_name} Employee via API"
34
35
end
0 commit comments