I am attempting to get the 'title' from within an array called 'itemType'. 'itemType' is an attribute inside my model 'Item'.
ie: Item { attributes: { name, id, itemType: { title, icon } }
I have been able to get what I want, but only for a single item. I can not in any way loop through the items to access the whole database at once and get the title for each individual item. Ruby yells at me with :
undefined method `[]' for nil:NilClass
So far I have::
<% i = 0 %>
<% len = Item.all.length %>
<% while i < len do %>
<% items = Item.include_object(:itemType)[i] %>
<div class="iso_holder">
<%= item.attributes['itemType']['title']%>
</div>
<% i += 1 %>
<% end %>
Any help would be appreciated :)
UPDATE:
Item Model:
class Item < ParseResource::Base
fields :objectId, :itemType, :user, :createdAt, :updatedAt, :ACL
validates_presence_of :user
belongs_to :user
end
[]is Ruby unhappy with? The call on line #4 or #6? Also, what'sinclude_object?