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

質問編集履歴

3

comment修正

2021/04/26 21:04

投稿

ryota1107
ryota1107

スコア6

title CHANGED
File without changes
body CHANGED
@@ -56,7 +56,7 @@
56
56
  def show
57
57
  @post = Post.find(params[:id])
58
58
  @comment = Comment.new
59
- @coments = @post.comments
59
+ @comments = @post.comments
60
60
 
61
61
  end
62
62
 

2

postに修正

2021/04/26 21:04

投稿

ryota1107
ryota1107

スコア6

title CHANGED
File without changes
body CHANGED
@@ -93,7 +93,7 @@
93
93
  belongs_to :user
94
94
  has_one_attached :image
95
95
  belongs_to :season
96
- has_many :Comment
96
+ has_many :comment
97
97
  with_options presence: true do
98
98
  validates :tops
99
99
  validates :pants

1

post.rbの追記

2021/04/26 20:58

投稿

ryota1107
ryota1107

スコア6

title CHANGED
File without changes
body CHANGED
@@ -86,4 +86,23 @@
86
86
  params.require(:comment).permit(:text).merge(user_id: current_user.id, post_id: params[:post_id])
87
87
  end
88
88
  end
89
+ ```
90
+ ```post
91
+ class Post < ApplicationRecord
92
+ extend ActiveHash::Associations::ActiveRecordExtensions
93
+ belongs_to :user
94
+ has_one_attached :image
95
+ belongs_to :season
96
+ has_many :Comment
97
+ with_options presence: true do
98
+ validates :tops
99
+ validates :pants
100
+ validates :shoes
101
+ validates :season_id
102
+ validates :image
103
+ validates :season_id, numericality: { other_than: 1 }
104
+ end
105
+ end
106
+
107
+ ```
89
- ```![イメージ説明](7d4e4cd4825a3507b21b1a593b80139c.png)
108
+ ![イメージ説明](7d4e4cd4825a3507b21b1a593b80139c.png)