This repository was archived by the owner on Nov 13, 2020. It is now read-only.
File tree 4 files changed +147
-3
lines changed
4 files changed +147
-3
lines changed Original file line number Diff line number Diff line change 1
1
class BespokeController < ApplicationController
2
+ # GET /posts
3
+ # GET /posts.json
4
+ def index
5
+ @posts = Post . all
6
+
7
+ render json : @posts
8
+ end
9
+
10
+ # GET /posts/1
11
+ # GET /posts/1.json
12
+ def show
13
+ @post = Post . find ( params [ :id ] )
14
+
15
+ render json : @post
16
+ end
17
+
18
+ # POST /posts
19
+ # POST /posts.json
20
+ def create
21
+ @post = Post . new ( params [ :post ] )
22
+
23
+ if @post . save
24
+ render json : @post , status : :created , location : @post
25
+ else
26
+ render json : @post . errors , status : :unprocessable_entity
27
+ end
28
+ end
29
+
30
+ # PATCH/PUT /posts/1
31
+ # PATCH/PUT /posts/1.json
32
+ def update
33
+ @post = Post . find ( params [ :id ] )
34
+
35
+ if @post . update ( params [ :post ] )
36
+ head :no_content
37
+ else
38
+ render json : @post . errors , status : :unprocessable_entity
39
+ end
40
+ end
41
+
42
+ # DELETE /posts/1
43
+ # DELETE /posts/1.json
44
+ def destroy
45
+ @post = Post . find ( params [ :id ] )
46
+ @post . destroy
47
+
48
+ head :no_content
49
+ end
2
50
end
Original file line number Diff line number Diff line change 1
1
class IdstyleController < ApplicationController
2
+ # GET /posts
3
+ # GET /posts.json
4
+ def index
5
+ @posts = Post . all
6
+
7
+ render json : @posts
8
+ end
9
+
10
+ # GET /posts/1
11
+ # GET /posts/1.json
12
+ def show
13
+ @post = Post . find ( params [ :id ] )
14
+
15
+ render json : @post
16
+ end
17
+
18
+ # POST /posts
19
+ # POST /posts.json
20
+ def create
21
+ @post = Post . new ( params [ :post ] )
22
+
23
+ if @post . save
24
+ render json : @post , status : :created , location : @post
25
+ else
26
+ render json : @post . errors , status : :unprocessable_entity
27
+ end
28
+ end
29
+
30
+ # PATCH/PUT /posts/1
31
+ # PATCH/PUT /posts/1.json
32
+ def update
33
+ @post = Post . find ( params [ :id ] )
34
+
35
+ if @post . update ( params [ :post ] )
36
+ head :no_content
37
+ else
38
+ render json : @post . errors , status : :unprocessable_entity
39
+ end
40
+ end
41
+
42
+ # DELETE /posts/1
43
+ # DELETE /posts/1.json
44
+ def destroy
45
+ @post = Post . find ( params [ :id ] )
46
+ @post . destroy
47
+
48
+ head :no_content
49
+ end
2
50
end
Original file line number Diff line number Diff line change 1
1
class UrlstyleController < ApplicationController
2
+ # GET /posts
3
+ # GET /posts.json
4
+ def index
5
+ @posts = Post . all
6
+
7
+ render json : @posts
8
+ end
9
+
10
+ # GET /posts/1
11
+ # GET /posts/1.json
12
+ def show
13
+ @post = Post . find ( params [ :id ] )
14
+
15
+ render json : @post
16
+ end
17
+
18
+ # POST /posts
19
+ # POST /posts.json
20
+ def create
21
+ @post = Post . new ( params [ :post ] )
22
+
23
+ if @post . save
24
+ render json : @post , status : :created , location : @post
25
+ else
26
+ render json : @post . errors , status : :unprocessable_entity
27
+ end
28
+ end
29
+
30
+ # PATCH/PUT /posts/1
31
+ # PATCH/PUT /posts/1.json
32
+ def update
33
+ @post = Post . find ( params [ :id ] )
34
+
35
+ if @post . update ( params [ :post ] )
36
+ head :no_content
37
+ else
38
+ render json : @post . errors , status : :unprocessable_entity
39
+ end
40
+ end
41
+
42
+ # DELETE /posts/1
43
+ # DELETE /posts/1.json
44
+ def destroy
45
+ @post = Post . find ( params [ :id ] )
46
+ @post . destroy
47
+
48
+ head :no_content
49
+ end
2
50
end
Original file line number Diff line number Diff line change 2
2
root "homepage#index"
3
3
4
4
namespace "bespoke" do
5
- resources :posts
5
+ resources :posts , except : [ :new , :edit ]
6
6
end
7
7
8
8
namespace "idstyle" do
9
- resources :posts
9
+ resources :posts , except : [ :new , :edit ]
10
10
end
11
11
12
12
namespace "urlstyle" do
13
- resources :posts
13
+ resources :posts , except : [ :new , :edit ]
14
14
end
15
15
end
You can’t perform that action at this time.
0 commit comments