This is my Action model:
class Action < ActiveRecord::Base
end
class Fold < Action
end
class Check < Action
end
class Call < Action
end
class Bet < Action
end
In another model, I have this
class Deal < ActiveRecord::Base
def Deal.parse_action(action_string)
case action_string
when "folds": Fold.new()
when "checks": Check.new()
when "calls": Call.new()
when "bets": Bet.new()
when "raises": Bet.new()
else nil
end
end
# ...
end
Now, when I test this if this works in my unit tests, everything appears to work. But as soon as I start the web server in development mode, I get this:
NameError (uninitialized constant Deal::Fold): app/models/deal.rb:115:in `parse_action' ...
Why does it think Fold exists within the namespace Deal? And why does this not happen in the test environment?