質問編集履歴
2
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -136,10 +136,26 @@
|
|
136
136
|
|
137
137
|
Rails.application.routes.draw do
|
138
138
|
|
139
|
-
|
139
|
+
namespace :api do
|
140
140
|
|
141
|
+
namespace :v1 do
|
142
|
+
|
143
|
+
resources :restaurants do
|
144
|
+
|
145
|
+
resources :foods, only: %i[index]
|
146
|
+
|
147
|
+
end
|
148
|
+
|
141
|
-
|
149
|
+
resources :line_foods, only: %i[index create]
|
150
|
+
|
151
|
+
put 'line_foods/replace', to: 'line_foods#replace'
|
152
|
+
|
153
|
+
resources :orders, only: %i[create]
|
154
|
+
|
155
|
+
end
|
142
156
|
|
143
157
|
end
|
144
158
|
|
159
|
+
end
|
160
|
+
|
145
161
|
```
|
1
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,40 +1,136 @@
|
|
1
1
|
現在rails APIとcreate-react-appで用意したreactを使用して開発をしています。
|
2
2
|
|
3
|
-
Herokuにデプロイしたのち、react-routerを動かそうとしていますが上手くいきません。どなたかご教授お願いします。
|
3
|
+
Herokuにデプロイしたのち、react-routerを動かそうとしていますが上手くいきません。どなたかご教授お願いします。また、react-routerとrailsのルーティングのソースコードは以下の通りです。
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
```public/App.```ここに言語を入力
|
8
|
-
|
9
|
-
コード
|
10
|
-
|
11
|
-
```js
|
12
4
|
|
13
5
|
|
14
6
|
|
15
7
|
|
16
8
|
|
9
|
+
**src/App.js**
|
10
|
+
|
11
|
+
```React.js
|
12
|
+
|
13
|
+
import './App.css';
|
14
|
+
|
15
|
+
import {
|
16
|
+
|
17
|
+
BrowserRouter as Router,
|
18
|
+
|
19
|
+
Switch,
|
20
|
+
|
21
|
+
Route,
|
22
|
+
|
17
|
-
|
23
|
+
} from "react-router-dom";
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
// components
|
28
|
+
|
29
|
+
import { Restaurants } from './containers/Restaurants.jsx';
|
30
|
+
|
31
|
+
import { Foods } from './containers/Foods.jsx';
|
32
|
+
|
33
|
+
import { Orders } from './containers/Orders.jsx';
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
function App() {
|
38
|
+
|
39
|
+
return (
|
40
|
+
|
41
|
+
<Router>
|
42
|
+
|
43
|
+
<Switch>
|
44
|
+
|
45
|
+
<Route
|
46
|
+
|
47
|
+
exact
|
48
|
+
|
49
|
+
path="/">
|
50
|
+
|
51
|
+
<Restaurants />
|
52
|
+
|
53
|
+
</Route>
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
<Route
|
58
|
+
|
59
|
+
exact
|
60
|
+
|
61
|
+
path="/restaurants">
|
62
|
+
|
63
|
+
<Restaurants />
|
64
|
+
|
65
|
+
</Route>
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
<Route
|
70
|
+
|
71
|
+
exact
|
72
|
+
|
73
|
+
path="/foods"
|
74
|
+
|
75
|
+
>
|
76
|
+
|
77
|
+
<Foods />
|
78
|
+
|
79
|
+
</Route>
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
<Route
|
84
|
+
|
85
|
+
exact
|
86
|
+
|
87
|
+
path="/orders">
|
88
|
+
|
89
|
+
<Orders />
|
90
|
+
|
91
|
+
</Route>
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<Route
|
96
|
+
|
97
|
+
exact
|
98
|
+
|
99
|
+
path="/restaurants/:restaurantId/foods"
|
100
|
+
|
101
|
+
render={({ match }) =>
|
102
|
+
|
103
|
+
< Foods
|
104
|
+
|
105
|
+
match={match}
|
106
|
+
|
107
|
+
/>
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
/>
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
</Switch>
|
118
|
+
|
119
|
+
</Router>
|
120
|
+
|
121
|
+
);
|
122
|
+
|
123
|
+
}
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
export default App;
|
18
128
|
|
19
129
|
```
|
20
130
|
|
21
|
-
class ApplicationController < ActionController::API
|
22
131
|
|
23
|
-
def fallback_app_js
|
24
132
|
|
25
|
-
respond_to do |format|
|
26
|
-
|
27
|
-
format.js { render body: Rails.root.join('public/App.js').read }
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
```
|
36
|
-
|
37
|
-
**routes.rb**
|
133
|
+
**config/routes.rb**
|
38
134
|
|
39
135
|
```
|
40
136
|
|