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 4329102
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:46:43+00:00 2026-05-21T09:46:43+00:00

I have two models, User Membership The two have the following relationship with one

  • 0

I have two models,

User 
Membership

The two have the following relationship with one another

user has_many :memberships

I’ve been trying to figure out where the build method resides, and how do i get it in a list of methods for the instance. Here is the output of the debugger that shows my delima

(rdb:63) @user.memberships.respond_to?"build"
true

While the following is returning false, shouldnt it return true??

(rdb:63) @user.memberships.instance_methods.include?"build"
false
  • 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-05-21T09:46:43+00:00Added an answer on May 21, 2026 at 9:46 am

    One point is that instance_methods takes an optional boolean parameter, indicating whether you want to see methods of the instances ancestors. In your case I think you want instance_methods(true).

    However, it appears that “build” is an autogenerated method, according to the documentation. Typically the autogenerated methods in ActiveRecord are implemented by overriding method_missing and handling calls to “methods” that don’t actually exist. responds_to is also overridden so that the class will indicate that it responds to the correct calls. However, since those “methods” aren’t actually defined, they won’t show up in the instance_methods list.

    Since the list of commands that a class can respond_to using method_missing is essentially infinite, I’m pretty sure there’s no way to get the list. For example, an ActiveRecord model that has attributes a,b,c, and d will automatically respond to calls such as find_by_a_and_b and find_by_a_b_and_c and find_by_b_and_d and so forth, ad infinitum. There’s no way to get a list of all of those possibilities.

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

Sidebar

Related Questions

I have two Models called User and Membership. User has_many :memberships Membership belongs_to :user
I have two models: User and Car with the following associations: User has_many Car
I have two models, User and Profile, in one-to-one relation and I am trying
I have two models, User and Account. Each user may have one account. Creating
I have two models: User has_many :prices Price belongs_to :users I want to show
I have two models: User and HairColor. A user has only one hair color,
I have two models: Company and User they have a has_and_belongs_to_many relationship. I'm using
I have two models indexed for searching (User and Item). I'm trying to do
So, I have two models, User and Thing. User has_many :things end Thing belongs_to
I have two models: UserProfile (extended from user) and Cv . I created another

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.