Am I crazy?

Brian, when you run the console, you're not in a request/response cycle - IE you don't have access to Controllers.

If you wanted, you could test your settings within a functional test - which simulates the browser/server cycle.

The methods you place in application.rb will be available to other controllers. Create another controller and action - then refer to them.

I may have come into this conversation late - as I don't know what you're trying to do.

Cheers, Jodi General Partner The nNovation Group inc. www.nnovation.ca/blog

on-innovation.gif

Given your initial post I suspect you're confused about class vs. instance methods, and perhaps some other scoping rules as well.

If you're new to ruby and/or oop, I suggest you sit down with a good book, e.g. 'programming ruby' or 'ruby for rails'.

HTH, Isak

> Given your initial post I suspect you're confused about class vs. > instance methods, and perhaps some other scoping rules as well. > > If you're new to ruby and/or oop, I suggest you sit down with a good > book, e.g. 'programming ruby' or 'ruby for rails'. > > HTH, > Isak

It may seem that way, but while not a pro by any means, I think I have a fairly good grasp of all this. I've been working with Ruby for about two years, and Rails for about 9 months.

The reason I asked "Am I crazy?" is because this makes no sense, and I'm not sure if I understand it correctly. Whether my defining this method in the application controller makes for good programming or not, the question was, *should* it work? It seems the answers is, yes, it should, regardless of my particular abuse of it.

I am (was?) sure this did work until 3 days ago. Suddenly, no. Am I crazy?

It makes perfect sense. There's no way it could have worked 3 days ago.

ggironda$ script/console Loading development environment. >> self.class => Object >>

IRB, and by extension, script/console boot you into the top level. Any methods defined in individual classes are just that - defined in their individual classes. It would make no sense for script/console to boot you into the context of an instance of ApplicationController.

Something like what you want to achieve can be accomplished like this:

ggironda$ script/console Loading development environment. >> x = ApplicationController.new => #<ApplicationController:0x380389c> >> irb x >> self.class => ApplicationController >>

From that point, you'd be able to call the "msg" method. Not being able to access that method by default makes complete sense - it's an instance method on a class that doesn't have an instance around yet, and even when instantiated, you need to force IRB to be in the context of that instance.

For "msg" to be available "everywhere", you want to define it on module Kernel or class Object:

>> class Object; def msg; "msg" end; end => nil >> msg => "msg" >> module Kernel; def other_msg; "other" end; end => nil >> other_msg => "other" >>

This, however, is of questionable programming practice. Hope that cleared things up.

- Gabriel