Display all values in the show.html.erb originally selected in the form.

Let me re-format the parameters for you a little and see if you can spot the problem:

{   "utf8"=>"✓",   "authenticity_token"=>"3aeYhNBVYaFdHpPHWR5qpoD3QDB8PRUJIiR94WC1kag=",   "appointment"=>{     "physician_id"=>"4",     "patient_id"=>"8",     "reason"=>"fdsdfs",     "appointment_date(1i)"=>"2014",     "appointment_date(2i)"=>"12",     "appointment_date(3i)"=>"3",     "diagnostic_code_id"=>"1",     "notes"=>"sdfsdfs",     "appt_completion"=>"true"   },   "appointment_time"=>{     "test"=>"7"   },   "commit"=>"Create Appointment" }

Scott Ribe wrote in post #1163866:

{   "utf8"=>"✓",   "authenticity_token"=>"3aeYhNBVYaFdHpPHWR5qpoD3QDB8PRUJIiR94WC1kag=",   "appointment"=>{     "physician_id"=>"4",     "patient_id"=>"8",     "reason"=>"fdsdfs",     "appointment_date(1i)"=>"2014",     "appointment_date(2i)"=>"12",     "appointment_date(3i)"=>"3",     "diagnostic_code_id"=>"1",     "notes"=>"sdfsdfs",     "appt_completion"=>"true"   },   "appointment_time"=>{     "test"=>"7"   },   "commit"=>"Create Appointment" }

Is my problem the formatting of the appointment_time field in the appointments params? Or is the value that is planned for insert constrained by a single string input such as "7" rather than "test" => "7"?

I tried to remove the "test" => segment to just leave the index, or even better retrieve the value. I don't see any spelling errors, but I do know the insert is not typical of String values.

Scott Ribe wrote in post #1163866:

{ "utf8"=>"✓", "authenticity_token"=>"3aeYhNBVYaFdHpPHWR5qpoD3QDB8PRUJIiR94WC1kag=", "appointment"=>{    "physician_id"=>"4",    "patient_id"=>"8",    "reason"=>"fdsdfs",    "appointment_date(1i)"=>"2014",    "appointment_date(2i)"=>"12",    "appointment_date(3i)"=>"3",    "diagnostic_code_id"=>"1",    "notes"=>"sdfsdfs",    "appt_completion"=>"true" }, "appointment_time"=>{    "test"=>"7" }, "commit"=>"Create Appointment" }

Is my problem the formatting of the appointment_time field in the appointments params? Or is the value that is planned for insert constrained by a single string input such as "7" rather than "test" => "7"?

I tried to remove the "test" => segment to just leave the index, or even better retrieve the value. I don't see any spelling errors, but I do know the insert is not typical of String values.

I think he's trying to point out to you that the appointment_time field is not inside the appointment hash. So when that hash is used to update the @appointment instance, that value will not be added to it. It comes back around to how your form element was made. If you used the "bound" form helpers, as in f.text_field(:appointment_time) to make it, then the name attribute in the HTML would be <input name="appointment[appointment_time]" ...> and the value of that variable would be in the appointment hash.

Walter

Walter Davis wrote in post #1163868:

   "appointment_date(3i)"=>"3",

appointment_time field

is not inside the appointment hash. So when that hash is used to update the @appointment instance, that value will not be added to it. It comes back around to how your form element was made. If you used the "bound" form helpers, as in f.text_field(:appointment_time) to make it, then the name attribute in the HTML would be <input name="appointment[appointment_time]" ...> and the value of that variable would be in the appointment hash.

Walter

I do understand this. I tried to input f.select or form.select for this array drop down but I recieved an error for both so I left select alone and then it displayed. So I was thinking of encapsulating my array drop down into a bigger form element. I have f.label on the line above but the array select would not run with the f.

"displayed", great, but it doesn't work. Not a good tradeoff :slight_smile:

What was the error? What did you find when you googled that error? How did your code compare to the documentation for that method?

Hassan Schroeder wrote in post #1163871:

I do understand this. I tried to input f.select or form.select for this array drop down but I recieved an error for both so I left select alone and then it displayed.

"displayed", great, but it doesn't work. Not a good tradeoff :slight_smile:

What was the error? What did you find when you googled that error? How did your code compare to the documentation for that method?

-- Hassan Schroeder ------------------------ hassan.schroeder@gmail.com Hassan Schroeder | about.me twitter: @hassan

undefined method `merge' for #<Array:0x5c68788> in appointments/_form.html.erb

<%= f.select "appointment_time", "test", timeslots.map.with_index{

name, index|

       [name,         name] } %>

I found other examples undefined method 'merge' but did not find a solution although I found direction to create my array and array handling method in the controller. I tried different ways to display the array dropdown and the code above (without the f.) was the first time I was able to see the array in dropdown form. It felt like a relief.

undefined method `merge' for #<Array:0x5c68788> in appointments/_form.html.erb

OK, good, but --

How did your code compare to the documentation for that method?

<%= f.select "appointment_time", "test", timeslots.map.with_index{ >name, index| [name, name] } %>

From the ActionView::Helpers::FormBuilder doc example:

<%= f.select :person_id, Person.all.collect { |p| [ p.name, p.id ] }, include_blank: true %>

How do those two method signatures differ? Hint: what does "test" in the first one represent?

Hassan Schroeder wrote in post #1163878:

You might - easiest way to find out is try it :slight_smile: