Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Check out <a href="http://guides.rubyonrails.org/form_helpers.html" rel="nofollow">this reference</a>, where it says:</p> <blockquote> <p>2.2 Binding a Form to an Object</p> <p>While this is an increase in comfort it is far from perfect. If Person has many attributes to edit then we would be repeating the name of the edited object many times. What we want to do is somehow bind a form to a model object, which is exactly what form_for does.</p> </blockquote> <p>It goes on to show examples and elaborate on the discussion. So, the fields you use in the form_for are that model's fields. To show an example, in:</p> <pre><code>&lt;%= form_for Feed.new, id: "feed_add" do |f| %&gt; &lt;%= f.submit "Add Feed", class: 'formlabel' %&gt; &lt;%= f.text_field :feed_url, class: 'forminput', :autocomplete =&gt; :off %&gt; &lt;% end %&gt; </code></pre> <p>the model is Feed and the text_field is :feed_url, so this updates Feed.feed_url. It is returned to the controller in params[:feed]['feed_url']. </p> <p>If you can show your model, I can advise further. </p> <p>To follow up on the other part of your question, "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?", that's a bit different.</p> <p>If what you want to do is build an array, you might want to use form_tag instead of form_for. form_for is specifically for models. form_tag is a more generalized interface for objects not necessarily models. You can see that in the same <a href="http://guides.rubyonrails.org/form_helpers.html" rel="nofollow">reference</a>. To show an example:</p> <pre><code>&lt;%= form_tag feeds_path, method: 'get', id: "feed_search" do %&gt; &lt;%= submit_tag " Search ", feed_url: nil, class: 'formlabel' %&gt; &lt;%= text_field_tag :search, params[:search], class: 'forminput', :autocomplete =&gt; :off %&gt; &lt;% end %&gt; </code></pre> <p>Here, the value of :search is returned in params[:search].</p> <p>Regarding how to do it, you should return this information to your controller where it can process it. Views are for display. The controller can easily build and process the array so that it can be used in its decisions and/or routing. </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.
 

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