Including problems

T

T E

I have a file (index.rb) that includes head.rb. head.rb has a class
"Page" and in it, method "start". The problem is that when calling
Page.start I get this error: "uninitialized constant
#<Module:0x2a9e2793f8>::page (NameError)" it is pretty frustrating, can
anyone tell me whats wrong with it?
 
B

Brian Schröder

I have a file (index.rb) that includes head.rb. head.rb has a class
"Page" and in it, method "start". The problem is that when calling
Page.start I get this error: "uninitialized constant
#<Module:0x2a9e2793f8>::page (NameError)" it is pretty frustrating, can
anyone tell me whats wrong with it?

If you are inside of another modules namespace, maybe you'd need to directly address the Page class you want. Otherwise, please try to cut down the code to a minimal example and post it here.

E.g.

::page.new.start

hope to help,

Brian
 
J

Joel VanderWerf

T said:
Page.start( 'Message Boards', 'Message Boards', nil )

This is sending the #start method to Page. In other words, it is calling
a class method.
class Page
def start( page_title = nil, page_header = nil, page_caption = nil )

This defines an _instance_ method of class Page. You can call #start on
instances of Page, but not on Page itself.

Maybe what you want is

class Page
def self.start(...)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,190
Latest member
Martindap

Latest Threads

Top