这是我的约会控制人。在这里,为什么user_id在这里获得NIL?虽然我已经拥有了user_id。 关联:约会has_many Notes,用户has_many Notes,Notes belongs_to User,Notes belongs_to Appointment
def new
@appointment = Appointment.new
@note = @appointment.notes.build({user_id: current_user.id})
end
def create
@appointment = Appointment.new(appointments_params)
@appointment.patient_id = current_user.id
if @appointment.save
flash[:notice] = "Appointment saved!"
redirect_to authenticated_root_path
else
render 'new'
end
end
private
def appointments_params
params.require(:appointment).permit(:date, :doctor_id, :patient_id, :image, :starting_time, notes_attributes: [:id, :description, :user_id, :_destroy])
end