0

From MySQL database I got params in this format. Now I am unable to access this data. I have taken this value in variable.

Code: @text =

--- !map:HashWithIndifferentAccess 
q5_areaOf: 
- Mathematics
- Commerce
q7_residenceCity: Indore
q6_email: james@yahoo.com
action: patient_forms_save
controller: form_assigned_patients
q8_password: "123456"
q3_name: Rahul
formID: "12772743492"
q4_sex: Male

Now I want to display the whole data on rhtml page.

halfer
  • 19,824
  • 17
  • 99
  • 186
Rubyist
  • 6,486
  • 10
  • 51
  • 86

1 Answers1

0

If you don't want to output each attribute manually, you could loop through the HashWithIndifferentAccess like this:

<% @text.each do |key,value| %>
  <%= key %>: <%= value %>
<% end %>

or put it in a table:

<table>
  <% @text.each do |key,value| %>
    <tr>
      <td><%= key %></td>
      <td><%= value %></td>
    </tr>
  <% end %>
</table>

Best regards

Tobias

tbuehlmann
  • 9,032
  • 5
  • 27
  • 33