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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:33:44+00:00 2026-05-12T09:33:44+00:00

http://gist.github.com/172341 ( stackoverflow was breaking the formatting ) In the following case method name

  • 0

http://gist.github.com/172341 ( stackoverflow was breaking the formatting )

In the following case method name created by Human is not available to Boy. Is my understanding correct that attr_accessor methods are not
available to subclasses. I need to use superclass to access the method added by attr_accessor.

  • 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-12T09:33:44+00:00Added an answer on May 12, 2026 at 9:33 am

    What you’re looking for is cattr_accessor which fixes this specific problem:

    http://apidock.com/rails/Class/cattr_accessor

    Here’s your example, fixed:

    class Human
      def self.age
        @age = 50
      end
      def self.age=(input)
        @age = input
      end
    
      cattr_accessor :name
    
      self.name = 'human'
    end
    class Boy < Human
    end
    
    puts Human.age
    puts Boy.age
    puts Human.name
    puts Boy.superclass.name
    puts Boy.name # => 'human'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I used the html2haml converter to convert the following: https://gist.github.com/1379702 from http://css-tricks.com/2361-jquery-ui-tabs-with-nextprevious/ to
I installed Rails 3 by following this gist: http://gist.github.com/296055 But when I try rails
I followed all of the instructions so far from: http://code.google.com/p/appengine-jruby/wiki/RunningRails and http://gist.github.com/268192 Currently, I'm
I have an XML file full of bookmarks from Google Bookmarks. (File: http://gist.github.com/324844 )
Small toy app can be found here: http://gist.github.com/517445 I am trying to send artificial
I'm writing a git-install.sh script: http://gist.github.com/419201 To get Git's latest stable release version number,
Here is the stack trace which appears on resque-web interface: http://gist.github.com/396893 There you can
I have managed to run a basic rails app1 on App Engine using: http://gist.github.com/268192
http://gist.github.com/232194 I know it's something wrong with my transformations in drawGuy. Can anyone help
Rileshttps://gist.github.com/1265585 I'm getting an error (NoMethodError (undefined method `error' for true:TrueClass)) while trying to

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.