2
레일즈 5.0.0을 사용하고 있습니다. 나는이 모델belongs_to 필드를 선택 사항으로 만들려면 어떻게해야합니까?
class Scenario < ApplicationRecord
belongs_to :grading_rubric
has_many :confidential_memo
end
을 가지고 있지만 내가 모델 내 만들 방법을 호출 할 때, 그것은 내가 belongs_to는 것을 나타냅니다 어떻게 내가 오류가
full messages: ["Grading rubric must exist"]
입니다
def create
@scenario = Scenario.new(scenario_params)
respond_to do |format|
if @scenario.save
puts "saved successfully."
format.html { redirect_to confidential_memo_path(@scenario), notice: 'Saved successfully.' }
else
puts "full messages: #{@scenario.errors.full_messages}"
format.html { render action: "show" }
end
end
end
실패 인수는 선택적이어야합니다 (즉, null이 될 수 있습니까?).