teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

タイトル

2016/12/14 08:13

投稿

NishidaRyu416_
NishidaRyu416_

スコア113

title CHANGED
@@ -1,1 +1,1 @@
1
- Rails エラ発生
1
+ 親のない、レコドの更新について
body CHANGED
File without changes

2

コントローラの追加

2016/12/14 08:13

投稿

NishidaRyu416_
NishidaRyu416_

スコア113

title CHANGED
File without changes
body CHANGED
@@ -52,4 +52,23 @@
52
52
  favorites.where(user_id: user.id).exists?# exists?の説明 user.idが一致する人を探す。いたら、true いなかったら false
53
53
  end
54
54
  end
55
+ ```
56
+ コントローラー
57
+ ```ruby
58
+ def new
59
+ @words = Word.new
60
+ end
61
+
62
+ def create
63
+ word=words_params
64
+ word.each do |word|
65
+ @word = Word.create word
66
+ end
67
+ if @word.save
68
+ flash[:success] = "success!"
69
+ redirect_to @word
70
+ else
71
+ render 'new'
72
+ end
73
+ end
55
74
  ```

1

リンク

2016/12/14 04:47

投稿

NishidaRyu416_
NishidaRyu416_

スコア113

title CHANGED
File without changes
body CHANGED
@@ -1,5 +1,5 @@
1
1
  #回答よろしくお願いします
2
- [エラーのページ](https://gyazo.com/2e9c3fe7e74ddb732a315510f1b920ca)
2
+ [エラーのページ](https://gyazo.com/1fc90da0cb9f36a066062dd2e3bc0945)
3
3
  ```ruby
4
4
  <div class="col-md-6 col-md-offset-3">
5
5
  <h1>テスト作成</h1>