Ruby on rails RubyonRails“;SystemStackError堆栈级别太深“;错误
我是RubyonRails的新手,我正在尝试构建一个简单的博客平台,允许用户使用Desive进行身份验证。当我填写带有标题和内容字段的帖子表单时,当我按下“创建帖子”按钮时,我得到一个错误,显示Ruby on rails RubyonRails“;SystemStackError堆栈级别太深“;错误,ruby-on-rails,ruby,Ruby On Rails,Ruby,我是RubyonRails的新手,我正在尝试构建一个简单的博客平台,允许用户使用Desive进行身份验证。当我填写带有标题和内容字段的帖子表单时,当我按下“创建帖子”按钮时,我得到一个错误,显示 SystemStackError in PostsController#create stack level too deep 似乎我的PostsController中的“创建”操作就是问题的根源。有人能帮我吗?这是我的PostsController的外观: class PostsController
SystemStackError in PostsController#create stack level too deep
似乎我的PostsController中的“创建”操作就是问题的根源。有人能帮我吗?这是我的PostsController的外观:
class PostsController < ApplicationController
before_action :authenticate_user!
def index
@posts = Post.all
end
def new
@post = Post.new
end
def create
@post = Post.new(params[:post])
end
def show
@post = Post.find(params[:id])
end
private
def params
params.require(:post).permit(:title, :content)
end
end
class PostsController
简单,您可以在params
方法(递归)的主体中调用params
方法-boom,无限循环。更改自定义params
方法的名称:
def create
@post = Post.new(post_params)
# etc.
end
# ...
def post_params
params.require(:post).permit(:title, :content)
end
简单,在
params
method(递归)的主体中调用params
method-boom,无限循环。更改自定义params
方法的名称:
def create
@post = Post.new(post_params)
# etc.
end
# ...
def post_params
params.require(:post).permit(:title, :content)
end
非常感谢兄弟!!工作!!非常感谢兄弟!!工作!!