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

  • Home
  • SEARCH
  • 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 9148543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:18:16+00:00 2026-06-17T11:18:16+00:00

Maybe I am overlooking something obvious but I’m trying to apply a practical scenario

  • 0

Maybe I am overlooking something obvious but I’m trying to apply a practical scenario to this rails for Zombies tutorial.

——–Question————
Assuming the models and relationships are properly defined, find all the weapons that belong to Zombie ‘Ash’.

class Zombie < ActiveRecord::Base
  has_many :weapons
end

class Weapon < ActiveRecord::Base
  belongs_to :zombie
end

The tutorial accepts the answer of-

z = Zombie.find(1)
[#<Zombie ­id: 1, nam­e: "Ash", ­graveyard:­ "Glen Hav­en Memoria­l Cemetery­">]

z.weapons
[#<Weapon ­id: 1, nam­e: "Hammer­", strengt­h: 1, zomb­ie_id: 1>]

but for me that is not so practical, as if I were working on the project and that type of question came up I would do this.

ash = Zombie.where(:name => "Ash")
[#<Zombie ­id: 1, nam­e: "Ash", ­graveyard:­ "Glen Hav­en Memoria­l Cemetery­">]

But

ash.weapons

gives the output

#<NoMetho­dError: un­defined me­thod `weap­ons' for #­<ActiveR­ecord::Rel­ation:0x00­0000163347­38>>

How can this be when the output for finding the zombie is exactly the same and the way I found the zombie is much more practical given the way the question is framed (even though they provide db tables). Could it be a nuance with the codeschool interactive console or am I missing something?

Thanks for your attention.

  • 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-17T11:18:17+00:00Added an answer on June 17, 2026 at 11:18 am

    As your result shows itself:

    [#<Zombie ­id: 1, nam­e: "Ash", ­graveyard:­ "Glen Hav­en Memoria­l Cemetery­">]
    

    This is some sort of beefed up array.
    so if you would do:

    ash = Zombie.where(:name => "Ash").first
    ash.weapons
    

    will return all the weapons.

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

Sidebar

Related Questions

Maybe I am overlooking something obvious, but I have seen in code where you
Maybe this is a poor question, but, I can't find a tutorial or even
I am probably overlooking something obvious but then maybe someone else will too. I'm
I'm new to PHP so maybe I am overlooking something here but the following:
Maybe it's been a long day and I've overlooked something, but this is driving
maybe I'm drastically overlooking something trivial, but is there any possibility in Vim (with
Maybe I am overlooking something very easy and obvious... I have a method interface
Maybe I'm overlooking something, and hopefully this is done very easy. I have a
Ok I must be overlooking something extremely simple but I am lost. Given this
Maybe it's because of the dark outside, but I can't get this Position geom_text

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.