Error message

heey guyes, i need some help. i got this error message:
Error in application
NameError - uninitialized constant GreeterController
classpath:/./main.rb:51
classpath:/./main.rb:1:in `require’

this is my script:

48 begin
49 # Your application code goes here
50 require ‘/greeter/greeter_model’
51 GreeterController.instance.open
52 rescue => e
53 show_error_dialog_and_exit(e)
54 end

and the greeter_model is in a folder greeter in my Main.rb file.
this is my greeter_model:

class GreeterController < ApplicationController
set_model ‘GreeterModel’
set_view ‘GreeterView’
set_close_action :exit

def improve_button_action_performed
model.message = “But Swing with Monkeybars is awesome!”
update_view
end
end

i am doing a tutorial from monkeybars but i do everything right i know
that but i got that error (the only thing that i changed was <require
‘greeter_controller’ to require ‘/greeter/greeter_controller’> because
it otherwise while give a error messages that he can’t find
“greeter_model”

so i hope i explained my problem whele, so that you guys could help me
:stuck_out_tongue:

so please help me

On Fri, Nov 26, 2010 at 3:25 PM, Lark W. [email protected]
wrote:

50 require ‘/greeter/greeter_model’
set_view ‘GreeterView’
‘greeter_controller’ to require ‘/greeter/greeter_controller’> because

You say you changed “<require ‘greeter_controller’ to require
‘/greeter/greeter_controller’>” but your code shows that you are
requiring
‘/greeter/greeter_model’
Try requiring the controller again instead of the model. If it complains
that it can’t find the model, try requiring the model then requiring the
controller :slight_smile: I think you are probably confused here, because you showed
code that defined the GreeterController, but your file is the
greeter_model
file. I would expect the GreeterModel to be in the greeter_model file,
and
the GreeterController to be in the greeter_controller file.

Regarding putting the ‘/’ at the beginning, that is probably not right.
A
leading slash means you are telling it to search from the root folder of
your system rather than the current dir of the file. I am surprised that
you
didn’t get a load error (perhaps MonkeyBars overrides require and
doesn’t
throw an error?). Anyway, if your file defines the GreeterController,
but it
can’t find the GreeterController, then your file must not have gotten
loaded.

As a sanity check, you can try replacing the ‘greeter/greeter_model’
with
the full path to the file for your system. So on my system, that might
look
like
‘/Users/joshuacheek/deleteme/monkeybars-tutorial/greeter/greeter_model’
(I don’t know Windows conventions, it might look very different if you
are
on Windows).

If that doesn’t fix the issue, then this is probably not the problem.
But if
it does, then you just need to fix the require statements.

The general trick that I use to avoid errors when requiring files
relative
to the current file:
require File.dirname(FILE) + ‘/greeter/greeter_model’

And if that doesn’t work, maybe try:
File.expand_path( File.join FILE , ‘…’ , ‘greeter’ ,
‘greeter_model’ )

Its disgusting to look at, but it should allow you to almost certainly
find
the file that you are looking for (assuming it is in the correct place
and
named correctly).

heey i love you man :stuck_out_tongue: my problem whas that i had to require those other
file this is what it had to be:

require ‘greeter/greeter_model’
require ‘greeter/greeter_view’
require ‘greeter/greeter_controller’
GreeterController.instance.open

so thanks