From: Josh Cheek Date: 2010-11-27T07:32:17+09:00 Subject: Re: error message --0016362842de53a7600495fc4b21 Content-Type: text/plain; charset=ISO-8859-1 On Fri, Nov 26, 2010 at 3:25 PM, Lark Work wrote: > 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 '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 > :P > > so please help me > > -- > Posted via http://www.ruby-forum.com/. > > You say you changed "" 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 :) 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). --0016362842de53a7600495fc4b21--