Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 137031f

Browse files
committed
adds employee json resource
1 parent 9e0ba5d commit 137031f

File tree

7 files changed

+30
-3
lines changed

7 files changed

+30
-3
lines changed

‎app/controllers/employee_controller.rb

Lines changed: 0 additions & 2 deletions
This file was deleted.

‎app/controllers/employees_controller.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class EmployeesController < AuthorizedController
2+
3+
end

‎app/models/employee.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
class Employee < ApplicationRecord
2-
has_many :orders
32
end

‎app/resources/employee_resource.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
class EmployeeResource < JSONAPI::Resource
2+
attributes :title, :created_at, :first_name
23
end

‎config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
jsonapi_resources :posts
66
jsonapi_resources :users
77
jsonapi_resources :roles
8+
jsonapi_resources :employees
89
end

‎db/seeds.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@
2020
tokens: nil
2121
).add_role n == 0 ? :admin : :user
2222
end
23+
24+
20.times do |n|
25+
FactoryGirl.create(:employee)
26+
end

‎spec/factories/employee.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FactoryGirl.define do
2+
factory :employee do
3+
last_name { Faker::Name.last_name }
4+
first_name { Faker::Name.first_name }
5+
title { Faker::Name.title }
6+
title_of_courtesy { Faker::Name.title }
7+
birth_date { Faker::Date.backward(720) }
8+
hire_date { Faker::Date.backward(10) }
9+
address { Faker::Address.street_address }
10+
city { Faker::Address.city }
11+
region { Faker::Address.state }
12+
postal_code { Faker::Address.postcode }
13+
country { Faker::Address.country }
14+
home_phone { Faker::PhoneNumber.phone_number }
15+
extension { 'jpg' }
16+
photo { Faker::Placeholdit.image("50x50") }
17+
notes { Faker::Lorem.paragraph }
18+
created_at { Faker::Date.backward(20) }
19+
updated_at { Faker::Date.backward(15) }
20+
end
21+
end

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /