Note that there are some explanatory texts on larger screens.

plurals
  1. POConcatenate multiple fields on submit into a single array/field
    primarykey
    data
    text
    <p>I have two models: QuestionnaireResult and QuestionnaireOption.</p> <p>The options are dynamic. </p> <p>QuestionnaireResult has two columns: date_submitted and results. I want the results column to be some sort of array of the QuestionnaireOption and their value...</p> <p>i.e.</p> <pre><code>option_id / value 1 / 50 2 / false 3 / true </code></pre> <p>I submit data using this form, however it's not complete and not working because I don't know what name to give the text_fields <code>(undefined method 'not_sure_what_to_name_this' for #&lt;Admin::QuestionnaireResult:0x4a5ef9&gt;</code>):</p> <pre><code>&lt;%= form_for(@questionnaire_result) do |f| %&gt; &lt;% if @questionnaire_result.errors.any? %&gt; &lt;div id="error_explanation"&gt; &lt;h2&gt;&lt;%= pluralize(@questionnaire_result.errors.count, "error") %&gt; prohibited this questionnaire_result from being saved:&lt;/h2&gt; &lt;ul&gt; &lt;% @questionnaire_result.errors.full_messages.each do |msg| %&gt; &lt;li&gt;&lt;%= msg %&gt;&lt;/li&gt; &lt;% end %&gt; &lt;/ul&gt; &lt;/div&gt; &lt;% end %&gt; &lt;% @questionnaire_options.each do |questionnaire_option| %&gt; &lt;% if questionnaire_option.field_type == 'Textbox' %&gt; &lt;div class="field"&gt; &lt;%= f.label questionnaire_option.option %&gt;&lt;br /&gt; &lt;%= f.text_field :not_sure_what_to_name_this %&gt; &lt;/div&gt; &lt;% elsif questionnaire_option.field_type == 'Checkbox' %&gt; &lt;div class="field"&gt; &lt;%= f.label questionnaire_option.option %&gt;&lt;br /&gt; &lt;%= f.check_box :not_sure_what_to_name_this %&gt; &lt;/div&gt; &lt;% end %&gt; &lt;% end %&gt; &lt;div class="actions"&gt; &lt;%= f.submit %&gt; &lt;/div&gt; &lt;% end %&gt; </code></pre> <p>What name do I give text_field and how do I go about saving the results and storing them in a column as an array? Or is there better ways of going about this?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload