누군가가 도움이되기를 바랍니다. 다른 "param is missing"질문을 통해 검색했지만, 무엇이 잘못되었는지를 파악할 수 없습니다. 내 경로에params가 없거나 값이 비어있는 이유는 확실하지 않습니다.
내가이 중첩 된 자원 "행동"
resources :jobs do
resources :actions
end
관련 모델을 가지고 파일. "action_reference"를 무시하십시오. 그건 다른거야.
class Job < ActiveRecord::Base
has_many :actions
end
class Action < ActiveRecord::Base
belongs_to :job
belongs_to :action_reference
end
내가
button_to 사용하여 POST 요청을하여 새로운 액션을 만들려고 해요 여기 여기 ActionsController
class ActionsController < ApplicationController
before_action :set_job
before_action :set_action, only: [:show, :edit, :update]
# GET /jobs/:job_id/actions/:id
def show
end
# GET /jobs/:job_id/actions/new
def new
@action = Action.new
end
# GET /jobs/:job_id/actions/:id/edit
def edit
end
# POST /jobs/:job_id/actions/
def create
@action = @job.actions.create(action_params)
if @action.save
flash[:success] = "Next step successfully added."
redirect_to jobs_path
else
flash[:danger] = @action.errors.full_messages.join(", ")
redirect_to new_job_action_path
end
end
# PATCH to /jobs/:job_id/actions/:id
def update
if @action.update(action_params)
flash[:success] = "Next step successfully updated."
redirect_to jobs_path
else
flash[:danger] = @action.errors.full_messages.join(", ")
redirect_to edit_job_action_path
end
end
private
def set_job
@job = Job.find(params[:job_id])
end
def set_action
@action = Action.find(params[:id])
end
def action_params
params.require(:action).permit(:action_reference_id, :job_id, :completed_at, :next_action_date)
end
end
의 그리고 나의 button_to
<%= button_to answer[:text], post_action_jobs_path(@job), method: "post", params: { action: { action_reference_id: answer[:action_reference_id], job_id: @job_id , completed_at: answer[:action_completed_at], next_action_date: answer[:next_action_date] } }, type: "button", class: "btn btn btn-info btn-block" %>
I의 문제는 내가 t의 post_action_jobs_path에 전달하는 인수와 관련이 있다는 것을 알아라. 그는 컨트롤러에서 action_params로 전달하는 코드를 보거나 그 코드를 알아낼 수 없습니다. 나는이 프로그램을 실행할 때
나는 오류 얻을 : 난 당신이 뭔가를 사용해야하므로 "동작", 레일에서 예약어 인에 대해 뭔가 말을 조금 전에 일부 스레드를 보았다
undefined method `permit' for "create":String Did you mean? print
을하지만, 그게 사실이라면 나는 그것에 대해 어떻게 가야할지 모르겠다.
어떤 도움을 크게