我一直无法克服这个错误。它说它的“文本”是未定义的。
class PostsController < ApplicationController
before_action :set_post, only: [:show, :edit, :update, :destroy]
def create
@post = Post.new(post_params)
respond_to do |format|
if @post.save # (this line is highlighted in the error)
format.html { redirect_to @post, notice: 'Post was successfully created.' }
format.json { render action: 'show', status: :created, location: @post }
else
format.html { render action: 'new' }
format.json { render json: @post.errors, status: :unprocessable_entity }
end
end
end
当我最初使用 title:string body:text 'rails generate' 脚手架时,这很好用。
我整天都被这个问题困住了。建议会很棒。