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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:07:11+00:00 2026-05-27T19:07:11+00:00

How do I list all the methods that a particular object has access to?

  • 0

How do I list all the methods that a particular object has access to?

I have a @current_user object, defined in the application controller:

def current_user
  @current_user ||= User.find(session[:user_id]) if session[:user_id]
end

And want to see what methods I have available to me in the view file. Specifically, I want to see what methods a :has_many association provides. (I know what :has_many should provide, but want to check that.)

  • 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-27T19:07:11+00:00Added an answer on May 27, 2026 at 7:07 pm

    The following will list the methods that the User class has that the base Object class does not have…

    >> User.methods - Object.methods
    => ["field_types", "maximum", "create!", "active_connections", "to_dropdown",
        "content_columns", "su_pw?", "default_timezone", "encode_quoted_value", 
        "reloadable?", "update", "reset_sequence_name", "default_timezone=", 
        "validate_find_options", "find_on_conditions_without_deprecation", 
        "validates_size_of", "execute_simple_calculation", "attr_protected", 
        "reflections", "table_name_prefix", ...
    

    Note that methods is a method for Classes and for Class instances.

    Here’s the methods that my User class has that are not in the ActiveRecord base class:

    >> User.methods - ActiveRecord::Base.methods
    => ["field_types", "su_pw?", "set_login_attr", "create_user_and_conf_user", 
        "original_table_name", "field_type", "authenticate", "set_default_order",
        "id_name?", "id_name_column", "original_locking_column", "default_order",
        "subclass_associations",  ... 
    # I ran the statements in the console.
    

    Note that the methods created as a result of the (many) has_many relationships defined in the User class are not in the results of the methods call.

    Added Note that :has_many does not add methods directly. Instead, the ActiveRecord machinery uses the Ruby method_missing and responds_to techniques to handle method calls on the fly. As a result, the methods are not listed in the methods method result.

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

Sidebar

Related Questions

What's the shortest, one-liner way to list all methods defined with attr_accessor ? I
I have a method which compares two objects and returns a list of all
How can I list all instantiated objects in all application, using FASTMM4 or default
This is a Rails 3 application. I have images that can be tied to
Lets say I have the following one-to-many relationship: Site has many Users User belongs
I'm attempting to return a list of observers associated with a particular object using
I am trying to get a list of roles for a particular user (not
I have some classes that all implement the same Java interface, which essentially allows
I have an interface that contains a single method called ListAll() using System.Collections.Generic; namespace
I need to list all files whose names start with 'SomeLongString'. But the case

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.