MIddleman foreach local object key not found

22 Views Asked by At

Here is my template.html.erb loop. I am trying to access the JSON object data. This works, if I use just straight json arrays, ["name","artist","details"] and access it via artwork[0] artwork[1] etc. However, Im trying to use a JSON object and things fall apart.

<% data.artworks.each_with_index do |artwork,index| %>
<div id="<%= slug_text artwork.name %>" class="port">
  <div class="port_wrap">

    <div class="grid">
        <div class="c-50--lap-and-up grid__cell">
        <div class="title-box">
          <h1><%= artwork.name %></h1>
          <h2>By: <%= artwork.artist %></h2>

Im getting "undefined method 'name' for #Array:0x000005584bcd3018 as an error.

0

There are 0 best solutions below