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

The Archive Base Latest Questions

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

I have never seen this error message before undefined method `new’ for Book:Module and

  • 0

I have never seen this error message before

undefined method `new' for Book:Module

and was wondering if anyone knew why i am getting it, my first thought is naming conventions but am unsure

I have a module

  module Book::BookFinder

  BOOK_URL = 'https://itunes.apple.com/lookup?isbn='

  def book_search(search)
  response = HTTParty.get(BOOK_URL + "#{search}", :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' })
 results = JSON.parse(response.body)["results"]
end

end

and then include it within my controller

 class BookController < ApplicationController
 before_filter :authenticate_admin_user!
 include Book::BookFinder


 def results
 results = book_search(params[:search])
 @results = results
 @book = Book.new
 @book.author = results[0]["artistName"]

end

def create
@book = Book.new(params[:book])
 if @book.save
redirect_to @book, notice: 'Book was successfully saved'
 else
render action:new
end
end
end

has anyone come across this before and know how to fix it?

Thanks

  • 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-16T23:18:16+00:00Added an answer on June 16, 2026 at 11:18 pm

    The issue comes from your use of Book.new.

    Book is a Module (Book::BookFinder) and that can’t be instanced.

    The Methods inside Book::BookFinder are now mixed into your controller and any methods in Book::BookFinder can be called directly on the controller without having to instance Book::BookFinder.

    If you really want this to be a object use class instead of Module.

    Update:
    You obviously can’t just replace module with class.
    But if you want to have a object Book that you can new and set properties on you need to write a class for that (and remove the include Book::BookFinder you now used for the Module.

    A sample calss would look like this:

    class Book
      def initialize
        # put constructor logic here
      end
    
      def some_method
        # methods that can be called on the instance
        # eg:
        # @book = Book.new
        # @book.some_method
      end
    
      # defines a get/set property
      attr_accessor :author
      # allows assignment of the author property
    end
    

    Hope this helps, but I strongly suggest you check out some tutorials on Ruby classes and how these things work.

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

Sidebar

Related Questions

This is a new one I have never seen before. I have a gridview
Apologies in advance but I have never seen this error before and don't know
I have never seen this before, the rows will be sequential but I have
Hello i am new to android development I have never seen this type of
I am not strong on my PHP knowledge, but I have never seen this
I have seen this talked about but never answered. Maybe it has and I'm
I'm wondering why I have never seen the following way to implement templates in
I have done this many times and have never seen this. I have an
I have an error/exception that is thrown by a particular method. Any time this
I have never seen this but i had this thing in my mind! stack

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.