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 953b842

Browse files
authored
Merge branch 'master' into tgn-north-customers
2 parents 19b74fd + 863bcb8 commit 953b842

File tree

7 files changed

+61
-2
lines changed

7 files changed

+61
-2
lines changed

‎app/controllers/suppliers_controller.rb

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
@@ -6,4 +6,5 @@
66
jsonapi_resources :users
77
jsonapi_resources :roles
88
jsonapi_resources :customers
9+
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 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: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,16 @@
1313
end
1414

1515
25.times do |n|
16-
u = User.create!(email: "user#{n}@example.com", password: 'Secret123', confirmed_at: Time.now)
17-
u.add_role n == 0 ? :admin : :user
16+
User.create!(
17+
email: "user#{n}@example.com",
18+
password: 'Secret123',
19+
confirmed_at: Time.now,
20+
tokens: nil
21+
).add_role n == 0 ? :admin : :user
22+
end
23+
24+
25.times do |n|
25+
FactoryGirl.create(:supplier)
1826
end
1927

2028
25.times do |n|

‎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)

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