jeudi 18 octobre 2018

How to pass changed values from text_field_tag to the controller

My view file:

<% @result.each do |singleAttr| %> <!-- Now the singleAttr is a hash -->
<%= form_tag(change_policy_attr_values_path(singleAttr)) do %>
<tr class="<%= cycle('even', 'odd') %>">
<td><%= label_tag(:attrId,singleAttr["attrId"]) %></td>
<td><%= label_tag(:name,singleAttr["name"]) %></td>
<td style="word-break: break-all;"><%= text_field_tag(:value,singleAttr['value']) %></td>
<td style="text-align: center;">
    <%= submit_tag('Update',:id => "update_button") %> 
</td>
</tr>
<% end %>
<% end %>

Controller file:

def change
  attribValue = params[:value]
  render text: attribValue
end

When i change the value in the text_field_tag and after clicking on update submit button, i am getting the old value. How can i pass the updated text to the controller ?

This is what i am getting in the URL:

http://localhost:3000/policy_attr_values/change?attrId=10&name=MAX_LOCAL_MASK_LENGTH&value=18

I changed the value to 17 in the textbox, but still it's taking 18

Any help?

Thanks,

Aucun commentaire:

Enregistrer un commentaire