質問編集履歴

2

問題点が絞られた

2018/04/18 16:25

投稿

rubyganbaru
rubyganbaru

スコア14

test CHANGED
File without changes
test CHANGED
@@ -6,212 +6,26 @@
6
6
 
7
7
  と表示され、ブラウザが開けません。
8
8
 
9
- ターミナルを見てもエラーの気配もなく、なぜ表示されないのか見当がつかないです。
10
-
11
- ###
12
-
13
- ec2-user:~/environment/portfolio (master) $ rails s
14
-
15
- => Booting Puma
16
-
17
- => Rails 5.1.6 application starting in development
18
-
19
- => Run `rails server -h` for more startup options
20
-
21
- Exiting
22
-
23
- /home/ec2-user/environment/portfolio/config/routes.rb:20:in `block (2 levels) in <top (required)>': undefined local variable or method `comments' for #<ActionDispatch::Routing::Mapper:0x00000003d74148> (NameError)
24
-
25
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/actionpack-5.1.6/lib/action_dispatch/routing/mapper.rb:1439:in `block (2 levels) in resources'
26
-
27
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/actionpack-5.1.6/lib/action_dispatch/routing/mapper.rb:1709:in `block in resource_scope'
28
-
29
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/actionpack-5.1.6/lib/action_dispatch/routing/mapper.rb:882:in `controller'
30
-
31
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/actionpack-5.1.6/lib/action_dispatch/routing/mapper.rb:1709:in `resource_scope'
32
-
33
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/actionpack-5.1.6/lib/action_dispatch/routing/mapper.rb:1438:in `block in resources'
34
-
35
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/actionpack-5.1.6/lib/action_dispatch/routing/mapper.rb:1701:in `with_scope_level'
36
-
37
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/actionpack-5.1.6/lib/action_dispatch/routing/mapper.rb:1436:in `resources'
38
-
39
- from /home/ec2-user/environment/portfolio/config/routes.rb:19:in `block in <top (required)>'
40
-
41
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/actionpack-5.1.6/lib/action_dispatch/routing/route_set.rb:436:in `instance_exec'
42
-
43
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/actionpack-5.1.6/lib/action_dispatch/routing/route_set.rb:436:in `eval_block'
44
-
45
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/actionpack-5.1.6/lib/action_dispatch/routing/route_set.rb:418:in `draw'
46
-
47
- from /home/ec2-user/environment/portfolio/config/routes.rb:1:in `<top (required)>'
48
-
49
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:286:in `load'
50
-
51
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:286:in `block in load'
52
-
53
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency'
54
-
55
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:286:in `load'
56
-
57
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/railties-5.1.6/lib/rails/application/routes_reloader.rb:55:in `block in load_paths'
58
-
59
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/railties-5.1.6/lib/rails/application/routes_reloader.rb:55:in `each'
60
-
61
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/railties-5.1.6/lib/rails/application/routes_reloader.rb:55:in `load_paths'
62
-
63
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/railties-5.1.6/lib/rails/application/routes_reloader.rb:18:in `reload!'
64
-
65
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/railties-5.1.6/lib/rails/application/routes_reloader.rb:41:in `block in updater'
66
-
67
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/file_update_checker.rb:81:in `execute'
68
-
69
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/railties-5.1.6/lib/rails/application/routes_reloader.rb:42:in `updater'
70
-
71
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/railties-5.1.6/lib/rails/application/routes_reloader.rb:31:in `execute_if_updated'
72
-
73
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/railties-5.1.6/lib/rails/application/finisher.rb:128:in `block in <module:Finisher>'
74
-
75
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/railties-5.1.6/lib/rails/initializable.rb:30:in `instance_exec'
76
-
77
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/railties-5.1.6/lib/rails/initializable.rb:30:in `run'
78
-
79
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/railties-5.1.6/lib/rails/initializable.rb:59:in `block in run_initializers'
80
-
81
- from /usr/local/rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:228:in `block in tsort_each'
82
-
83
- from /usr/local/rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
84
-
85
- from /usr/local/rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:431:in `each_strongly_connected_component_from'
86
-
87
- from /usr/local/rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:349:in `block in each_strongly_connected_component'
88
-
89
- from /usr/local/rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:347:in `each'
90
-
91
- from /usr/local/rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:347:in `call'
92
-
93
- from /usr/local/rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:347:in `each_strongly_connected_component'
94
-
95
- from /usr/local/rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:226:in `tsort_each'
96
-
97
- from /usr/local/rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:205:in `tsort_each'
98
-
99
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/railties-5.1.6/lib/rails/initializable.rb:58:in `run_initializers'
100
-
101
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/railties-5.1.6/lib/rails/application.rb:353:in `initialize!'
102
-
103
- from /home/ec2-user/environment/portfolio/config/environment.rb:5:in `<top (required)>'
104
-
105
- from config.ru:3:in `require_relative'
106
-
107
- from config.ru:3:in `block in <main>'
108
-
109
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/rack-2.0.4/lib/rack/builder.rb:55:in `instance_eval'
110
-
111
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/rack-2.0.4/lib/rack/builder.rb:55:in `initialize'
112
-
113
- from config.ru:in `new'
114
-
115
- from config.ru:in `<main>'
116
-
117
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/rack-2.0.4/lib/rack/builder.rb:49:in `eval'
118
-
119
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/rack-2.0.4/lib/rack/builder.rb:49:in `new_from_string'
120
-
121
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/rack-2.0.4/lib/rack/builder.rb:40:in `parse_file'
122
-
123
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/rack-2.0.4/lib/rack/server.rb:319:in `build_app_and_options_from_config'
124
-
125
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/rack-2.0.4/lib/rack/server.rb:219:in `app'
126
-
127
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:24:in `app'
128
-
129
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/rack-2.0.4/lib/rack/server.rb:354:in `wrapped_app'
130
-
131
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:80:in `log_to_stdout'
132
-
133
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:42:in `start'
134
-
135
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:135:in `block in perform'
136
-
137
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:130:in `tap'
138
-
139
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:130:in `perform'
140
-
141
- from /home/ec2-user/environment/portfolio/vendor/bundler/ruby/2.4.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
142
-
143
- from /home/ec2-
144
-
145
- (以降省略)
146
9
 
147
10
 
11
+ コメント機能搭載時に書いた以下のルーティングの記述が問題のようですが、何がダメなのか見当がつきません。
148
12
 
149
13
 
150
14
 
151
15
  ###
152
16
 
153
- コメント投稿機能実装前は正常に表示できたので、
17
+ resources:blogs do
154
18
 
155
- 関係あるかもわかりませんが、コメント投稿機能のコードを以下にのせます。
19
+   resources:comments
156
20
 
157
-
21
+ end
158
22
 
159
23
  ###
160
24
 
161
25
 
162
26
 
163
- rails g model Comment body:string blog:references
164
-
165
- rails db:migrate
27
+ 何かご存知の方がいらっしゃればご教授願いたいです。
166
28
 
167
29
 
168
30
 
169
- ・comment.rb
170
-
171
- belongs_to:blog
31
+ 何卒よろしくお願いいたします。
172
-
173
- validates :body, presence: true
174
-
175
-
176
-
177
- ・blog.rb
178
-
179
- has_many :comments
180
-
181
-
182
-
183
- .ルーティング
184
-
185
- resources:posts do
186
-
187
- resources:comments
188
-
189
- end
190
-
191
-
192
-
193
- ・コメントのコントローラ
194
-
195
- rails g controller Comments
196
-
197
-
198
-
199
- ・showのview
200
-
201
- <h3>Comments</h3>
202
-
203
- <%= form_for([@blogs,comments.build]) do |f| %>
204
-
205
- <p>
206
-
207
- <%= f.text_field :body%>
208
-
209
- </p>
210
-
211
- <p>
212
-
213
- <%=f.submit %>
214
-
215
- </p>
216
-
217
- <%end%>

1

タグの変更

2018/04/18 16:25

投稿

rubyganbaru
rubyganbaru

スコア14

test CHANGED
File without changes
test CHANGED
File without changes