i have an object array. i'm trying to loop through it and output results to a table. i want one of my table columns to be a rendered partial (form). but no matter in what row i submit it always sends me the locals of the last row output.
Is this normal behavior of rails or am i doing something wrong?
my view is :
%table.table.table-hover
%thead
%tr
%th User id
%th User email
%th Account name
%th Intercom Conversation
%tbody
- @users.each do |user|
%tr
%td= user.user_id
%td= user.user_email
%td= user.account_name
%td
- if user.intercom_conversation
%h4= user.intercom_conversation
= link_to('edit', '#', {class: 'edit'})
.conversation_edit
= render(partial: 'conversation_form', locals: {user_id: user.user_id, fault_id: @fault.fault_id})
my rendered partial is :
= form_tag('update_conversation', method: 'get')
= hidden_field_tag(:fault_id, fault_id)
= hidden_field_tag(:user_id, user_id)
yes
= radio_button_tag(:conversation, 0)
no
= radio_button_tag(:conversation, 1)
ignored
= radio_button_tag(:conversation, 2)
= submit_tag('Change')
i guess i should say all rendering (in browser are correct and no error is raised)
thanks in advance .
You're outputting a series of empty forms without closing tags. You need to pass a block to form_tag
and indent the contents for it to automatically add the needed </form>
tags.
= form_tag('update_conversation', method: 'get') do
= hidden_field_tag(:fault_id, fault_id)
= hidden_field_tag(:user_id, user_id)
yes
= radio_button_tag(:conversation, 0)
no
= radio_button_tag(:conversation, 1)
ignored
= radio_button_tag(:conversation, 2)
= submit_tag('Change')