Ruby路由 - 堆栈级别太深

时间:2017-01-22 19:23:45

标签: ruby-on-rails ruby routes

我有以下控制器:

class HomeController < ApplicationController

    def index
    end

    def next_match
        games = Invite.where('estado = "Confirmado" AND (user_id = ? OR postulation_id = ?) AND game_date >= ?',
        params[:user_id], params[:user_id], Date.today)
        respond_to do |format|
            format.json {   render json: games}
            end

    end
    private
    def params
        params.require(:games).permit(:user_id)
    end
end 

在我的路线文件中,我声明了一个发布路线以访问&#34; next_match&#34;方法。但是当我试一试时,我的堆叠水平太深了。错误。那是为什么?

路线&GT;

  get 'home/index'
  post '/games' => 'home#next_match'
  root 'home#index'

我的想法是在我的第一页内通过post methon获取一些数据。

谢谢。

1 个答案:

答案 0 :(得分:4)

你有一个名为params的方法,它一遍又一遍地调用自己(递归)。

尝试将其命名为其他内容:

def allowed_params
   params.require(:games).permit(:user_id)
end