我遇到此错误时遇到了问题。它说“文本”未定义。
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:rails body:text。”来生成'脚手架'时,这很好用。
我整天都被困在这个问题上。建议会很棒。
答案 0 :(得分:1)
您的视图正在访问属性text
,但它应该是body