0

I've got a rails update form like this:

<%= debug @ballot.scores %>
<%= simple_form_for(@ballot, :url => "/vote/#{@election.id}/ballot/#{@ballot.position}/submit", :method => :post, :html => {:class => 'form-horizontal' }) do |f| %>
  <% f.fields_for :scores do |builder| %>
    <div class="slider">Slider goes here!</div>
    <%= builder.hidden_field :initialValue, :value => 50 %>
  <% end %>
  <%= f.button :submit %>
<% end %>

The debug shows:

---
- !ruby/object:Score
  attributes:
    id: 1
    ballot_id: 4
    candidate_id: 4
    initialScore: 
    normalizedScore: 
    created_at: 2013-08-08 05:00:10.391163000 Z
    updated_at: 2013-08-08 05:00:10.432374000 Z
- !ruby/object:Score
  attributes:
    id: 2
    ballot_id: 4
    candidate_id: 5
    initialScore: 
    normalizedScore: 
    created_at: 2013-08-08 05:00:10.418904000 Z
    updated_at: 2013-08-08 05:00:10.434772000 Z

So there are definitely score objects, however no "Slider goes here!" text is showing up on the page. Why isn't this working?

Let me know if you need more info :)

1 Answer 1

1

You need to specify <%= fields_for ... you are missing the = sign.

Try:

<%= f.fields_for :scores do |builder| %>

Please refer to fields_for documentation on it's usage.

Although fields_for works regardless of use of simple_form, you could use simple_fields_for as well since you are using simple_form as follows:

<%= f.simple_fields_for :scores do |builder| %>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.