Measures when model cannot be created

I am creating an application with Ruby on rails, and when I did rails g model hoge (model name), I could not make a model for some reason, so I will write the cause and solution.

error contents

The result is as follows. 7e84474b2d5d2417dee0acf7d8e8569d.png

The name Diary means that it cannot be used because it is already in use. Since the application name was diary, I thought that I should change it, so I changed the folder name. After making the change, I did rails g model diary again ...

I got the exact same error: sweat:

Conclusion

You need to change the application name in the config file.

before

app/config/application.rb


module Diary ← The application name is displayed here
  class Application < Rails::Application
    config.load_defaults 6.0
  end
end

after

app/config/application.rb


module EveryDiary ← Change
  class Application < Rails::Application
    config.load_defaults 6.0
  end
end

By changing the name, I was able to create a model safely! I felt that I also needed to check the config file.

Recommended Posts

Measures when model cannot be created
Unexpected pitfalls when images cannot be displayed
[Android] Solution when the camera cannot be started on Android 9
[Rails] When using ajax, be aware of "CSRF measures".
Note when pip install mysqlclient cannot be installed on Mac
Because getSupportLoaderManager cannot be used
When JConsole cannot connect locally
Java Stream cannot be reused.
Text file placed in resources in Java cannot be read when jarted
"ClassNotFoundException" is displayed when tomcat is started in eclipse and cannot be started
When the certificate cannot be obtained by https-portal production (Response Code: 403)
Rails tutorial When rails new cannot be done due to different versions
[Ruby On Rails] In the create action and destroy action, emergency measures when redirect_to action:: show cannot be (cannot be used)