I have reviewed posts on this board and Google's search results on undefined method merge' and undefined method
delete' for the same variable in my project.
I have these relationships implemented in the corresponding models
class Appointment < ActiveRecord::Base
belongs_to :physician
belongs_to :patient
belongs_to :diagnostic_code
end
class Patient < ActiveRecord::Base
has_many :appointments
has_many :physicians, :through => :appointments
end
class Physician < ActiveRecord::Base
has_many :appointments
has_many :patients, :through => :appointments
end
Currently, I am trying to implement a collection select that will allow the user to select a physician and patient in the appointment creation process. The error I am currently receiving is:
undefined method `physician_id' for #
The error is below. This error is located in my appointments/form and is encountered when my program attempts to render a new form.
<div class="field">
<%= f.label :physician_id %><br>
<%= f.collection_select :physician_id, @physicians, :id, :full_name %>
</div>
<div class="field">
<%= f.label :patient_id %><br>
<%= f.collection_select :patient_id, @patients, :id, :full_name2 %>
</div>
I have scaffolded each of these fields correctly from my understanding and have copied and adjusted the code that has worked for other users experiencing this problem. I have also ran a migration afterwords.
The error has nothing to do with collection_select. The problem is with your f object. Please provide a screenshot of the error. The name of the class is missing in the error information you provided. You are using collection select right though.