I have a range_field that inside of a form_for and I am not sure how to correctly pass the values needed to the controller and to the database.

There does not seem to be very much information about range_field that I could find. This was the only question that was similar that I could find.

range_field(object_name, method, options = {}) public

I want it to save :value, :food_id, :user_id, :vas_question_id in a new vas_answer when I click Next. Do I need to utilize hidden_field to do this?

There could be 1-3 questions on each page. Would it be better/easier to save it as an array or as 3 separate answers?

Relevant code cut from my current view:

<%= form_for @answer do |answer| %> <% @foods.each do |food| %> # there could be 1, 2, or 3 foods <h4 class="col-md-offset-1 col-md-10" style="font-size: 16px; line-height: 1.6em; clear: both;"><%= @question.prompt_left %> <strong><%= food.name %></strong> <%= @question.prompt_right %></h4> <%= range_field :vas_answers, :value, min: 1, max: 500, step: 1, class: 'not-clicked', :food_id => food.id, :user_id => current_user.id, :vas_question_id => @question.order %> # I saw :user_id => user.id on another question so I tried it, but I don't know what it is really doing <% end %> <%= answer.submit 'Next', :class => 'col-md-offset-9 btn btn-primary btn-surv' %> <% end %>

Controller:

class VasAnswersController < ApplicationController before_filter :authenticate_user! def create @answer = VasAnswer.new(answer_params[:vas_answers]) @q_num = params[:order] # determine order of questions (not really relevant) @q_num = @q_num.to_i + 1 respond_to do |format| if @answer.save if @q_num < 25 format.html { redirect_to vas_questions_url(@q_num) } else format.html { redirect_to demographics_path} end end end end private def answer_params params.require(:vas_answers).permit(:value, :user_id, :vas_question_id, :food_id) end end

Route: