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

Scott R. 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.

On Dec 2, 2014, at 8:15 PM, Dmoneyzzz D. [email protected]
wrote:

“appointment_date(3i)”=>“3”,

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

On Dec 2, 2014, at 5:44 PM, Dmoneyzzz D. [email protected]
wrote:

[1m[35m (0.0ms)[0m begin transaction
[1m[36mSQL (1.0ms)[0m [1mINSERT INTO “appointments”
(“appointment_date”, “appt_completion”, “created_at”,
“diagnostic_code_id”, “notes”, “patient_id”, “physician_id”, “reason”,
“updated_at”) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)[0m
[[“appointment_date”, “2014-12-03”], [“appt_completion”, “t”],
[“created_at”, “2014-12-03 00:04:58.420420”], [“diagnostic_code_id”,
1.0], [“notes”, “sdfsdfs”], [“patient_id”, 8], [“physician_id”, 4],
[“reason”, “fdsdfs”], [“updated_at”, “2014-12-03 00:04:58.420420”]]

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”
}

Walter D. wrote in post #1163868:

On Dec 2, 2014, at 8:15 PM, Dmoneyzzz D. [email protected]
wrote:

“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.

On Tue, Dec 2, 2014 at 5:51 PM, Dmoneyzzz D. [email protected]
wrote:

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 S. ------------------------ [email protected]

twitter: @hassan

On Tue, Dec 2, 2014 at 7:29 PM, Dmoneyzzz D. [email protected]
wrote:

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 S. ------------------------ [email protected]

twitter: @hassan

Hassan S. wrote in post #1163871:

On Tue, Dec 2, 2014 at 5:51 PM, Dmoneyzzz D. [email protected]
wrote:

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 S. ------------------------ [email protected]
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.

On Tue, Dec 2, 2014 at 8:13 PM, Dmoneyzzz D. [email protected]
wrote:

Appears as though test is in the same location as Person.all.collect. if
I change test to something like appointment.all.collect I might get
another value…?

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


Hassan S. ------------------------ [email protected]

twitter: @hassan

Hassan S. wrote in post #1163878:

On Tue, Dec 2, 2014 at 7:29 PM, Dmoneyzzz D. [email protected]
wrote:

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, { |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 S. ------------------------ [email protected]
Hassan Schroeder | about.me
twitter: @hassan

Thanks for walking with me.

Appears as though test is in the same location as Person.all.collect. if
I change test to something like appointment.all.collect I might get
another value…?