rails初心者のものです。
調べてもわからなかったので、力を貸してくださると嬉しいです
PATCHが問題なのでしょうか・・・?
resources :posts と書きました rake routes以下 posts_path GET /posts(.:format) posts#index POST /posts(.:format) posts#create new_post_path GET /posts/new(.:format) posts#new edit_post_path GET /posts/:id/edit(.:format) posts#edit post_path GET /posts/:id(.:format) posts#show PATCH /posts/:id(.:format) posts#update PUT /posts/:id(.:format) posts#update DELETE /posts/:id(.:format) posts#destroy root_path GET / welcome#index
class PostsController < ApplicationController def new end def create @post = Post.new(post_params) @post.save redirect_to @post end def show @post = Post.find(params[:id]) end def index @posts = Post.all end def edit @post = Post.find(params[:id]) end def update @post = Post.find(params[:id]) @post.update(post_params) redirect_to @post end def destroy @post = Post.find(params[:id]) @post.destroy redirect_to posts_path end private def post_params params.require(:post).permit(:title, :text) end end
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。