0
所以我正在做lynda.com軌道課程。琳達當然在紅寶石軌道4不兼容
由於該課程是爲rails 3.1而記錄的,而且我現在在Rails 4上,他們現在正在實施strong_parameters。我添加了subject_params定義,以符合這一點,但現在我得到ActiveRecord :: RecordNotFound,當我嘗試在我以前申報的類節目上獲得params [:id]。波紋管是代碼。方法顯示以前工作正常。
class SubjectsController < ApplicationController
def show
@subject = Subject.find(params[:id])
end
def new
@subject = Subject.new(:name => 'default')
end
def create
# Instantiante a new object using form parameters
@subject = Subject.new(subject_params)
# Save the object
if @subject.save
# If save suceeds, redirect to the list action
redirect_to(:action => 'list')
else
# If save fails, redisplay the form so user can fix problems
render('new')
end
end
private
def subject_params
params.require(:subject).permit(:id, :name, :position, :visible)
end
end
你檢查的網址,這是什麼傳球, 建立在軌控制檯的對象,及檢查Subject.find(some_id)是否工作.. –