Processing Dynamically generated rails form -
After
I am trying to process the following input
parameter:. {"UTF8" = & gt; "✓", "authenticity_token" = & gt; "OgwCJx5J03kvFrve1B / BQ5jBlqsGaqP2En7sAe5XcBA =", "contact_attempt_id" => "79", "3" => "8", "7" => "22"}
I can easily obtain contact_attempt_id and response_code. The last two parameters are proven to be elusive.
The key is the database id for a query, while the value is the database id for the answer I have tried the loop through the questions that find the ID in the parameter hashes.
questions.each do | Q | if! Params [q.id] .nil? C = contact_responses.create c.question_id = q.id c.answer_id = params [q.id] end c.save
However I am not able to get the answer id.
Your id
will be an integer from the database parameter
Hash keys are wires / symbols
( HashWithIndifferentAccess
)
Change your code for this
questions Each do | Q | Until para [q.id.to_s]. Blanc? C = contact_responses.create c.question_id = q.id c.answer_id = params [q.id.to_s] .to_i c.save end
Comments
Post a Comment