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 19b74fd

Browse files
Add customers
1 parent 2fb5362 commit 19b74fd

File tree

8 files changed

+53
-0
lines changed

8 files changed

+53
-0
lines changed

‎app/controllers/customers_controller.rb

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,4 +5,5 @@
55
jsonapi_resources :posts
66
jsonapi_resources :users
77
jsonapi_resources :roles
8+
jsonapi_resources :customers
89
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
@@ -16,3 +16,7 @@
1616
u = User.create!(email: "user#{n}@example.com", password: 'Secret123', confirmed_at: Time.now)
1717
u.add_role n == 0 ? :admin : :user
1818
end
19+
20+
25.times do |n|
21+
FactoryGirl.create(:customer)
22+
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)

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