Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8398151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:58:13+00:00 2026-06-09T20:58:13+00:00

I am attempting to get the ‘title’ from within an array called ‘itemType’. ‘itemType’

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:58:14+00:00Added an answer on June 9, 2026 at 8:58 pm

    your code seems not to use the power or ruby

    This should help.

    <% Item.all.each do |item| %>
        <div class="iso_holder">
           <%= item.itemType.title unless item.itemType.nil? %>
        </div>
    <% end %>
    

    My Probable guess is you are getting itemType as nil somewhere in some record

    also have a short look at loops in ruby

    I personally feel its not worth using ruby if you are writing the same way you code in other langs 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to get the user's IP from inside of my upload handler, but
Im attempting to get a block of text from a file I have already
I am attempting to get a count of items in an array to place
I'm attempting to get order data from a Yahoo store. I'm using the docs
I am attempting to get all the data from a MySQL db with PHP,
I am attempting to get the index of the current item in a JCarousel
I'm attempting to get the values Title: some, song title Length: 5:35 Rating: 0
I am attempting to get a random bearing, from 0 to 359.9. SET bearing
I am attempting to get the information from one table (games) and count the
I'm attempting to get a KBDLLHOOKSTRUCT from a keyboard-hook's lParam. private static IntPtr HookCallback(int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.