How do I import ruby classes into the main file?
<p>I'm trying to learn how to program with Ruby and I want to create separate files for separate classes, but when I do I get the following message:</p>
<blockquote>
<p>NameError: uninitialized constant Book<br />
const_missing at org/jruby/RubyModule.java:2677</p>
<p>(root) at /Users/Friso/Documents/Projects/RubyApplication1/lib/main.rb:1</p>
</blockquote>
<p>However, it works if I put the class directly into the main file. How can I solve this?</p>
<p>Main code:</p>
<pre><code>book1 = Book.new(&quot;1234&quot;, &quot;Hello&quot;, &quot;Ruby&quot;)
book2 = Book.new(&quot;4321&quot;, &quot;World&quot;, &quot;Rails&quot;)

book1.to_string
book2.to_string
</code></pre>
<p>Class code:</p>
<pre><code>class Book
  def initialize(isbn,title,author)
    @book_isbn=isbn
    @book_title=title
    @book_author=author
  end
  
  def to_string
    puts &quot;Title: #@book_title&quot;
    puts &quot;Author: #@book_author&quot;
    puts &quot;ISBN: #@book_isbn&quot;
  end
end
</code></pre>