Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails RubyonRails“;SystemStackError堆栈级别太深“;错误_Ruby On Rails_Ruby - Fatal编程技术网

Ruby on rails RubyonRails“;SystemStackError堆栈级别太深“;错误

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

我是RubyonRails的新手,我正在尝试构建一个简单的博客平台,允许用户使用Desive进行身份验证。当我填写带有标题和内容字段的帖子表单时,当我按下“创建帖子”按钮时,我得到一个错误,显示

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

非常感谢兄弟!!工作!!非常感谢兄弟!!工作!!