I'm trying to create a non-ActiveRecord model in app/models/gamestate.rb
. Then inside my controller (PlayController) I should be able to do GameState.new
, right? No go:
NameError (uninitialized constant PlayController::GameState):
app/controllers/play_controller.rb:23:in `play'
(at least in the development environment)
But! If I do have a model called app/models/play.rb
, then it's automatically loaded and I can do Play.new
.
So my question is: how does Rails know which classes to load? What sort of name mangling does it do to get from play#action
to PlayController
to app/controllers/play_controller.rb
to app/models/play.rb
?
It seems awfully fragile, but maybe a better understanding of how this works would help.
And finally, how can I get it to load app/models/gamestate.rb
?