Skip to content

Commit f301fd2

Browse files
committed
Add suppliers
1 parent f369b8a commit f301fd2

File tree

7 files changed

+55
-0
lines changed

7 files changed

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

app/models/supplier.rb

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

app/resources/supplier_resource.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class SupplierResource < 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+
:home_page
13+
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 :suppliers
89
end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class CreateSuppliers < ActiveRecord::Migration[5.0]
2+
def change
3+
create_table(:suppliers) 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.text :home_page
15+
t.timestamps
16+
end
17+
end
18+
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+
25.times do |n|
25+
FactoryGirl.create(:supplier)
26+
end

spec/factories/supplier.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FactoryGirl.define do
2+
factory :supplier do
3+
company_name { Faker::Company.name }
4+
contact_name { Faker::Name.name }
5+
contact_title { Faker::Name.title }
6+
address { Faker::Address.street_address }
7+
city { Faker::Address.city }
8+
region { Faker::Address.state }
9+
postal_code { Faker::Address.postcode }
10+
country { Faker::Address.country }
11+
phone { Faker::PhoneNumber.cell_phone }
12+
fax { Faker::PhoneNumber.cell_phone }
13+
home_page { "http://#{Faker::Company.name}.com" }
14+
end
15+
end

0 commit comments

Comments
 (0)