Rails / MongoDB: Variable to address object-attribute not translating

66 views Asked by At

In my class AleShot I have some dynamic mongoid-attributes. In order to index them, I collect all attributes in an array called "dynamos". Now when I want to list these (see code below) I get: undefined method 'dyn_f' for #<AleShot:0x007f8f7ab18328> Any Ideas why the dyn_f-variable isn't translated correctly?

<% @ale_shots.each do |ale_shot| %>
  <tr>
    <td><%= ale_shot.name %></td>
    <% dynamos.each do |dyn_f| %>
        <td><%= ale_shot.dyn_f %></td>
    <% end %>
  </tr>
<% end %>
1

There are 1 answers

0
Santhosh On BEST ANSWER

That could be because dyn_f is not defined as a field in the model.

Access it like this

ale_shot['dyn_f']