Skip to content

Commit 1dd32a9

Browse files
authored
Merge pull request #15 from tnoworyta/tgn-north-customers
Add customers
2 parents 863bcb8 + 953b842 commit 1dd32a9

File tree

8 files changed

+53
-0
lines changed

8 files changed

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

app/models/customer.rb

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

app/resources/customer_resource.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class CustomerResource < JSONAPI::Resource
2+
attributes :company_name,
3+
:contact_name
4+
:contact_title
5+
:address
6+
:city
7+
:region
8+
:postal_code
9+
:country
10+
:phone
11+
:fax
12+
end

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
jsonapi_resources :posts
66
jsonapi_resources :users
77
jsonapi_resources :roles
8+
jsonapi_resources :customers
89
jsonapi_resources :suppliers
910
end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class CreateCustomers < ActiveRecord::Migration[5.0]
2+
def change
3+
create_table :customers, force: true do |t|
4+
t.string :company_name
5+
t.string :contact_name
6+
t.string :contact_title
7+
t.string :address
8+
t.string :city
9+
t.string :region
10+
t.string :postal_code
11+
t.string :country
12+
t.string :phone
13+
t.string :fax
14+
t.datetime :created_at
15+
t.datetime :updated_at
16+
end
17+
end
18+
end

db/seeds.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@
2424
25.times do |n|
2525
FactoryGirl.create(:supplier)
2626
end
27+
28+
25.times do |n|
29+
FactoryGirl.create(:customer)
30+
end

server/tmp/restart.txt

Whitespace-only changes.

spec/factories/customer.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FactoryGirl.define do
2+
factory :customer do
3+
company_name { Faker::Company.name }
4+
contact_name { Faker::Name.name }
5+
address { Faker::Address.street_address }
6+
city { Faker::Address.city }
7+
region { Faker::Address.state }
8+
postal_code { Faker::Address.zip_code }
9+
country { Faker::Address.country }
10+
phone { Faker::PhoneNumber.phone_number }
11+
fax { Faker::PhoneNumber.phone_number }
12+
end
13+
end

0 commit comments

Comments
 (0)