Google Groups

Re: begin/rescue for flow control

Avdi Grimm Apr 8, 2012 7:51 PM
Posted in group: Objects on Rails
On Sun, Apr 8, 2012 at 9:29 PM, Jim Gay <> wrote:
> Rails models/controllers are lazily loaded, so const_defined? might be
> false even though you have a file that defines that constant.

Bingo. Ruby's autoload has a way to ask if a constant can be
autoloaded, and I assume Rails' method does as well; ;but I wasn't
sure how reliable they are. I figured by actually letting Ruby try to
access the constant I'd be giving any autoload mechanisms the maximum
opportunity to work before falling back on a stub.

Avdi Grimm

I only check email twice a day. to reach me sooner, go to