質問編集履歴

3

edit.html.erbの追加

2021/05/20 04:01

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -190,6 +190,36 @@
190
190
 
191
191
  validates :industry_id, numericality: { other_than: 0 }
192
192
 
193
+
194
+
195
+ edit.html.erb
196
+
197
+
198
+
199
+ <body class="back-image">
200
+
201
+ <%= form_with(model: @enterprise, local: true) do |f| %>
202
+
203
+ <div class="enterprise-box">
204
+
205
+ 投稿
206
+
207
+ <%= f.collection_select(:industry_id, Industry.all, :id, :industry, {}, {class:"industry-select"}) %>
208
+
209
+ <%= f.text_field :title, class:"title", placeholder:"企業名" %>
210
+
211
+ <%= f.text_area :theme, class:"theme", placeholder:"選考段階・面接で聞かれたこと等々" %>
212
+
213
+ <%= f.text_area :text, class:"text", placeholder:"選考での感想やアドバイス" %>
214
+
215
+ <%= f.submit "変更" ,class:"btn" %>
216
+
217
+ </div>
218
+
219
+ <% end %>
220
+
221
+ </body>
222
+
193
223
  end
194
224
 
195
225
 

2

モデルの追加

2021/05/20 04:01

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -162,6 +162,36 @@
162
162
 
163
163
 
164
164
 
165
+ enterprise.rb モデル
166
+
167
+ class Enterprise < ApplicationRecord
168
+
169
+ validate extend ActiveHash::Associations::ActiveRecordExtensions
170
+
171
+ belongs_to :user
172
+
173
+ belongs_to :industry
174
+
175
+
176
+
177
+
178
+
179
+ with_options presence: true do
180
+
181
+ validates :title
182
+
183
+ validates :text
184
+
185
+ validates :theme
186
+
187
+ end
188
+
189
+
190
+
191
+ validates :industry_id, numericality: { other_than: 0 }
192
+
193
+ end
194
+
165
195
 
166
196
 
167
197
  #### 試したこと

1

エラーの該当箇所の記載です

2021/05/20 03:57

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -108,7 +108,7 @@
108
108
 
109
109
  def update
110
110
 
111
- if @enterprise.update(enterprise_params)
111
+ if @enterprise.update(enterprise_params) エラー該当箇所です
112
112
 
113
113
  redirect_to root_path
114
114