Skip to content

Commit 236de3a

Browse files
committed
Start server & client with foreman start
1 parent 57341e4 commit 236de3a

File tree

7 files changed

+31
-25
lines changed

7 files changed

+31
-25
lines changed

.foreman

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
procfile: Procfile.dev

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ gem 'devise_token_auth'
3232
group :development, :test do
3333
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
3434
gem 'byebug', platform: :mri
35+
gem 'foreman'
3536
end
3637

3738
group :test do

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ GEM
5959
faker (1.7.3)
6060
i18n (~> 0.5)
6161
ffi (1.9.18)
62+
foreman (0.82.0)
63+
thor (~> 0.19.1)
6264
globalid (0.3.7)
6365
activesupport (>= 4.1.0)
6466
i18n (0.8.1)
@@ -165,6 +167,7 @@ DEPENDENCIES
165167
devise_token_auth
166168
factory_girl
167169
faker
170+
foreman
168171
jsonapi-resources
169172
listen (~> 3.0.5)
170173
pg (~> 0.18)

Procfile.dev

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
web: bundle exec puma -p 3001
2+
webpack: cd client && npm start

README.md

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
1-
# README
1+
# [rails-json-api-react](https://github.com/tb/rails-json-api-react)
22

3-
## Rails API app setup
3+
## [DEMO](rails-json-api-react.herokuapp.com)
44

5-
rails new . -d postgresql --skip-javascript --api -T
5+
Demo user: user1@example.com / Secret123
66

7-
## jsonapi-resources setup
7+
## Setup app
88

9-
### Models
9+
bundle
10+
rake db:setup
11+
cd client && npm i
1012

11-
rails g model category name:string
12-
rails g model post title:string body:text category:references
13-
rails g model comment body:text post:references
14-
15-
### Resources
13+
## Start app
1614

17-
rails generate jsonapi:resource category
18-
rails generate jsonapi:resource post
19-
rails generate jsonapi:resource model
15+
foreman start
16+
open http://localhost:3000
2017

21-
### Controllers
18+
## Adding new JSON API resource
2219

20+
rails g model category name:string
21+
rails generate jsonapi:resource category
2322
rails g controller Category --skip-assets
24-
rails g controller Posts --skip-assets
25-
rails g controller Comments --skip-assets
2623

27-
### Routes
24+
### routes.rb
2825

2926
jsonapi_resources :categories
30-
jsonapi_resources :posts
31-
jsonapi_resources :comments
3227

33-
### Start app
34-
foreman start
28+
### Client
29+
30+
Add list, edit and form components in `client/src/components/` based on one of existing.

client/webpack.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ module.exports = removeEmpty({
4444

4545
devServer: ifDevelopment({
4646
host: '0.0.0.0',
47-
port: 8080,
47+
port: 3000,
48+
overlay: true,
4849
stats: 'normal',
4950
proxy: {
5051
'/**': {
51-
target: 'http://localhost:3000',
52+
target: 'http://localhost:3001',
5253
},
5354
}
5455
}),

db/seeds.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88

99
FactoryGirl.find_definitions
1010

11-
FactoryGirl.create_list(:category, 15, :with_posts)
11+
15.times do |n|
12+
FactoryGirl.create(:category, :with_posts)
13+
end
1214

1315
25.times do |n|
14-
User.create(email: "user#{n}@example.com", password: 'Secret99', confirmed_at: Time.now)
16+
User.create!(email: "user#{n}@example.com", password: 'Secret123', confirmed_at: Time.now)
1517
end

0 commit comments

Comments
 (0)