3

I just created my first Rails 6 project ruby 2.7.0 rails 6.0.3. I have the following file:

#app\models\foo.rb

class Foo
  def initialize
  end

  def bar
   puts("Whoohoo!")
  end
end

From rails console I am trying to run:

foo = Foo.new

And I keep getting the error:

Zeitwerk::NameError (expected file <mypath>/app/models/foo.rb to define constant Foo, but didn't)

Coming from Rails 5 I'm lost as to what I'm doing wrong.

Bingo
  • 31
  • 1
  • 6
  • It seems a similar issue was asked here https://stackoverflow.com/questions/57277351/rails-6-zeitwerknameerror-doesnt-load-class-from-module – Anna Costalonga Sep 14 '20 at 21:49

1 Answers1

1

Can be that puts("Whoohoo!) missing a quote, but the syntax parser would get, so I'm assuming that is not the case.

You can call ActiveSupport::Dependencies.autoload_paths in rails console to consult if your model it is actually being loaded.

Mateus Luiz
  • 756
  • 7
  • 20