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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:40:20+00:00 2026-06-18T14:40:20+00:00

Please tell me what am I doing wrong here. I want to be able

  • 0

Please tell me what am I doing wrong here. I want to be able to capitalize any string that is being added later in the code through the method titles .

class Book
  attr_accessor :book_title

  def initialize
       @book_title = String.new
     end

  def titles
    book_title.capitalize
  end

end

@book = Book.new
puts @book.titles = "steve jobs"

Because when I execute it, I get undefined method `titles=' for #<Book:0x007fbd25813d98 @book_title=""> (NoMethodError)

  • 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-18T14:40:22+00:00Added an answer on June 18, 2026 at 2:40 pm

    It’s a little unclear as to what you’re trying to accomplish. You’re adding an attr_accessor for book_title, not for titles (which isn’t a variable at all). You need to call

    puts @book.book_titles = "Steve Jobs"
    

    in order to set (and print) the title.

    If you’re trying to pass a title to titles and have that method capitalize the title and set @book_title to that, you need to declare it as an assignment method using =, pass in the parameter title, and actually set @book_title to that. Something like this

    def titles= title
      @book_title = title.capitalize
    end
    

    Currently your titles method only returns the capitalized local variable book_title, which doesn’t exist (it needs the @ to reference the instance variable).

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

Sidebar

Related Questions

Please tell me what am I doing wrong here. What I want to do
Could someone please tell me what I am doing wrong here. I have compiled
Can someone please tell me what I'm doing wrong here. I've done a post
Please can someone tell me what im doing wrong here with respect to calling
can someone please tell what I'm doing wrong here? \newcommand{\bc}{\small\begin{verbatim}} \newcommand{\ec}{\normalsize\end{verbatim}} and then \bc
Can someone please tell me what I'm doing wrong here? I get the following
Can you please tell me what's wrong with the following code? Panel div =
Please tell me if I got this wrong. Anchor point is like a movable
Please tell me why my window doesn't render. Below is the javascript that i
Hello I want to ask a question that is repeated here . I have

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.