0

我有以下代码行,但不知道为什么我收到错误“ActionController::ParameterMissing in LeaguesController#create param not found:league_name”:

class LeaguesController < ApplicationController
  def new
    @league = League.new
  end

  def create
    @league = League.new(league_params)
    if @league.save
        redirect_to payments_new_url
    else
        render 'new'
    end
  end

  private

  def league_params
    params.require(:league_name).permit(:league_url)
  end
end
4

1 回答 1

0

尝试要求league,因为它是对象,并允许 _name 和 _url

params.require(:league).permit(:league_url, :league_name)
于 2013-09-28T19:15:57.650 回答