プログラミング超初心者です。
投稿機能より本文入力後、実行すると
「Routing Error No route matches [POST] "/lists/lists"」
と、表示されます。
どのように修正すればよいでしょうか、、、
ルーティング Rails.application.routes.draw do get 'lists/new' post 'lists' => 'lists#create' get 'lists/index' get 'lists/show' get 'lists/edit' get "/top" => "homes#top" # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html end
コントローラー class ListsController < ApplicationController def new @lits = List.new end def create list = List.new(list_params) list.save redirect_to "/top" end def index end def show end def edit end private def list_params params.requier(:list).permit(:title, :body) end end
ビュー <h1>新規投稿</h1> <%= form_with model: @list, url: "lists", method: :post do |f| %> <h4>タイトル</h4> <%= f.text_field :title %> <h4>本文</h4> <%= f.text_area :body %> <%= f.submit "投稿" %> <% end %>
やってみたこと
form_with記載
createアクションの作成
このエラーについて調べる
・rails routesに記載されているか
・記載がなければ、ルーティングにリクエストされている
[POST] "/lists/lists"は存在しない。
どうぞよろしくお願いいたします。
あなたの回答
tips
プレビュー