0
我一直得到這個錯誤,我沒有在一段時間內使用紅寶石,所以我真的不知道如何解決它。ActionController :: ParameterMissing不知道什麼是錯的
param is missing or the value is empty: sch
Extracted source (around line #72):
70
71
72
73
74
# Never trust parameters from the scary internet, only allow the white list through.
def sch_params
params.require(:sch).permit(:date, :time, :user_id)
end
end
Rails.root: C:/Sites/web
Application Trace | Framework Trace | Full Trace
app/controllers/sches_controller.rb:72:in `sch_params'
app/controllers/sches_controller.rb:27:in `create'
Request
Parameters:
{"utf8"=>"✓",
"authenticity_token"=>"cHq54V7aVCjeBz0udZAYjGiojgrqDANx/BS+oMQ+N+0=",
"sche"=>{"date(1i)"=>"2014",
"date(2i)"=>"4",
"date(3i)"=>"21",
"time(1i)"=>"2014",
"time(2i)"=>"4",
"time(3i)"=>"21",
"time(4i)"=>"17",
"time(5i)"=>"37",
"user"=>"steve"},
"commit"=>"Create Sche"}
這是我的控制器
class SchesController < ApplicationController
before_action :set_sch, only: [:show, :edit, :update, :destroy]
# GET /sches
# GET /sches.json
def index
@sches = Sche.all
end
# GET /sches/1
# GET /sches/1.json
def show
end
# GET /sches/new
def new
@sch = Sche.new
end
# GET /sches/1/edit
def edit
end
# POST /sches
# POST /sches.json
def create
@sch = Sche.new(sch_params)
respond_to do |format|
if @sch.save
format.html { redirect_to @sch, notice: 'Sche was successfully created.' }
format.json { render :show, status: :created, location: @sch }
else
format.html { render :new }
format.json { render json: @sch.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /sches/1
# PATCH/PUT /sches/1.json
def update
respond_to do |format|
if @sch.update(sch_params)
format.html { redirect_to @sch, notice: 'Sche was successfully updated.' }
format.json { render :show, status: :ok, location: @sch }
else
format.html { render :edit }
format.json { render json: @sch.errors, status: :unprocessable_entity }
end
end
end
# DELETE /sches/1
# DELETE /sches/1.json
def destroy
@sch.destroy
respond_to do |format|
format.html { redirect_to sches_url }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_sch
@sch = Sche.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def sch_params
params.require(:sch).permit(:date, :time, :user)
end
end
我真的不知道怎麼回事,我已經試過googleing的問題,但我還沒有找到答案 任何幫助,將不勝感激感謝
啊這太尷尬了,我不敢相信我錯過了。非常感謝你 – user3018763
很高興提供幫助。 15分鐘超時結束後請接受答案。 :) –