rails 新規投稿について
解決したいこと
発生している問題・エラー
プログラミングを始めたばかりの者です。
Ruby on Railsで新規投稿画面を作成中です。
新規投稿画面はできたのですが投稿するとエラーになるので
解決方法を教えていただきたいです。
### 該当するソースコード
```言語名
``
ルート
Rails.application.routes.draw do
root to: 'homes#top'
get 'home/about' => 'homes#about'
devise_for :users
resources :post_clothe, only: [:new, :create, :index, :show]
end
``
コントローラー
class PostClotheController < ApplicationController
def new
@Post_clothe = PostClothe.new
end
def create
@post_clothe = PostClothe.new (post_clothe_params)
@post_clothe.user_id = current_user.id
@post_clothe.save
redirect_to post_clothe_path
end
def index
@Post_clothes = PostClothe.all
end
def show
end
private
def post_clothe_params
params.require(:post_clothe).permit(:title, :image, :explanation, :genre)
end
end```
0 likes



