oobie11
oobie11

Reputation: 925

How do I create a list of forms from an array?

Im on Rails 4. I have a two lists of objects that I want a page to display a form to update a field on each of them

<div class="row">
    <div class="col-md-6 col-md-offset-3">
        <h1>Teas</h1>
        <% @teas.each do |tea| %>
            <%= form_tag(controller: "teas", action: "update", method: "patch") %>
                <%= label_tag(:price, tea.name.titleize) %>
                <%= text_field_tag :price %>
            <% end %>
        <% end %>

        <h1>Mixins</h1>
        <% @mixins.each do |mixin| %>
            <%= form_tag(controller: "mixins", action: "update", method: "patch") %>
                <%= label_tag(:price, mixin.name.titleize) %>
                <%= text_field_tag :price %>
            <% end %>
        <% end %>
    </div>
</div>

When I use this, I get an syntax error, unexpected keyword_end, expecting end-of-input error. What is wrong here?

Upvotes: 1

Views: 47

Answers (1)

TM.
TM.

Reputation: 3741

Seems like you have missed do on form

<%= form_tag(controller: "teas", action: "update", method: "patch") do %>

Upvotes: 1

Related Questions