Monday, 19 August 2013

Rails pass array to partial using collection

Rails pass array to partial using collection

I'm trying to iterate through a regular array (not ActiveRecord), and
render a partial using each element.
In my view (I'm using slim):
== render partial: "layouts/display_elements", collection: my_array
My partial (for now) only contains:
= "#{display_element}"
However, I'm getting the following error:
undefined local variable or method `display_element' for
#<#<Class:0x007f7fe2e6ca58>:0x007f7fe51e0408>
Is this a limit of imposed by not using ActiveRecord? Do I have to resort to
= my_array.each do |e|

No comments:

Post a Comment