Rails - Loop not printing the data in liquid template

Viewed 673

I have pulled some records from database that look like as following and are assigned a variable called users

[#
<User id: 53433, first_name: "Héctor", last_name: "Pinzon">,
<User id: 53434, first_name: "Héctor 2", last_name: "Pinzon 2">,
]

Inside the liquid I want to iterate over them via loop

{% for user in users %}
{{ user.first_name }}
{% endfor %}

When I get the email where the first_name is supposed to appear it prints out

 Liquid error: internal 
 Liquid error: internal

What am i doing wrong here? Why the data from users does not appear?

2 Answers

You can pass an array of objects to Liquid but not another type of collection, like ActiveRecord::Relation.

If this is the case, users.to_a should work.

Related