Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.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 得到一个;未定义的方法“许可证和x27”;至于;创建&引用;提交表单时出错_Ruby On Rails - Fatal编程技术网

Ruby on rails 得到一个;未定义的方法“许可证和x27”;至于;创建&引用;提交表单时出错

Ruby on rails 得到一个;未定义的方法“许可证和x27”;至于;创建&引用;提交表单时出错,ruby-on-rails,Ruby On Rails,当我试图创建一个“动作”时,我得到了这个错误 我的行动控制器: class ActionsController < ApplicationController def new @match_set = MatchSet.find(params[:match_set_id]) @fixture = @match_set.fixture @teams = Team.where("id = " + @fixture.home_team_id.to_s + " OR

当我试图创建一个“动作”时,我得到了这个错误

我的行动控制器:

class ActionsController < ApplicationController

  def new
    @match_set = MatchSet.find(params[:match_set_id])
    @fixture = @match_set.fixture
    @teams = Team.where("id = " + @fixture.home_team_id.to_s + " OR id = " + @fixture.away_team_id.to_s)
    @players = Player.where("team_id = " + @teams.ids.first.to_s + " OR id = " + @teams.ids.last.to_s)
    @action = @match_set.actions.new
  end

  def create
    @match_set = MatchSet.find(params[:match_set_id])
    @action = @match_set.actions.new(action_params)

    if @action.save
      redirect_to match_set(@match_set)
    else
      render "actions/new"
    end
  end

  private
    def action_params
      params.require(:action).permit(:team_id, :player_id, :position, :action_type, :action_result)
    end
end
我在控制器的这一行上得到一个错误:

params.require(:action).permit(:team_id,:player_id,
:position,:action_type,:action_result)
我还注意到,我的参数似乎正在消失,但再次没有关于原因的线索

参数:

{"utf8"=>"✓", "authenticity_token"=>"BqbEOfL7hEA8XSMXDvMW2qQ2uR74Egp5
jJvtQlsuyV2TikZJ+6hTIEMH05gy8TM6r3ZglFDRUFBl7ScZD1czCQ==", 
"commit"=>"Add Action", "match_set_id"=>"15"}

非常感谢您的帮助。

action
是rails中的保留字。您需要更改型号名称

Rails为每个请求提供了几个参数,例如:

params[:controller] # maps to your controller name
params[:action]     # maps to an action with your controllers

我有另一个保留字的问题,但在尝试创建模型时收到警告,我更改了该警告。(“set”改为“match_set”)在我看来,没有提到任何未经许可的参数。我更深入地研究了“action”一词。您不应在控制器或模型中使用
操作
,如果可能,我建议更改模型名称。
{"utf8"=>"✓", "authenticity_token"=>"BqbEOfL7hEA8XSMXDvMW2qQ2uR74Egp5
jJvtQlsuyV2TikZJ+6hTIEMH05gy8TM6r3ZglFDRUFBl7ScZD1czCQ==", 
"commit"=>"Add Action", "match_set_id"=>"15"}
params[:controller] # maps to your controller name
params[:action]     # maps to an action with your controllers