과 다른 템플릿보기를 렌더링합니다. 그 중 두 가지는 중요한 것으로 보인다. 방법을 만들어 내레일 3.2.x 내가 코드의 추적 문자열을 시도하고 특정 ID
class Appointment < ActiveRecord::Base
attr_accessible :appointment_date, :appointment_notes, :appointment_time, :procedure_id, :patient_id
belongs_to :patient
belongs_to :procedure
validates :procedure_id, presence: true
validates :patient_id, presence: true
validates :appointment_date, presence: true
validates :appointment_time, presence: true
class Patient < ActiveRecord::Base
attr_accessible :address1, :address2, :city, :comment, :email, :first_name, :init_date, :init_time, :last_name, :mobile, :notes, :phone, :state, :zip
before_validation :upcase_patient
before_save { self.email.downcase! }
has_many :appointments, dependent: :destroy
has_many :procedures, through: :appointments
멋진 작동합니다. 그러나 데이터를 제출하고 약속에서 유효성 검사를 통과하지 않으면 정확한 app.dev/patients/ : id 페이지를 렌더링해야합니다. 여기서 : id는 현재 작업중인 페이지입니다. 문제의 양식은 (환자/쇼보기를 통해) 약속을 만드는 양식입니다. 잘못된 데이터 또는 무효 데이터가 제출되고 presence : true가 필요하면 동일한 페이지를 렌더링하고 싶습니다. 내가 현재받는 것은 :
RSpec에
ActionView::Template::Error:
undefined method `first_name' for nil:NilClass
# ./app/views/patients/show.html.erb:1:in `_app_views_patients_show_html_erb__4137167421928365638_70201005779320'
# ./app/controllers/appointments_controller.rb:11:in `create'
나는이 특별히 그에 따라 옳은 길을 렌더링을 설정할 수있는 함께 할 권리 환자/ID를 호출 할 수있다 생각한다. 어떤 도움이라도 대단히 감사하겠습니다.
잘 작동합니다. 고맙습니다. 그러나 추천 한대로 변수를 '비공개'로 설정하고 '보호'하지 않았습니다. 이 모든 것이 잘 진행되었습니다! 건배! – sandovalg