【Rails】scaffoldで画面作ろうとしたらつまづきました

$ rails g scaffold diary title:string body:text
Running via Spring preloader in process 2897
       invoke  active_record
 The name 'Diary' is either already used in your application or reserved by Ruby on Rails. Please choose an alternative and run this generator again.

その名前もうありますけどwみたいなエラー。

Diaryではない適当な名前(Blogとか)だとうまくできたのだけどDiaryはだめでした。(データベースがないよというエラーが出ましたけど)

テスト用にBlogを消したついでにDiaryも消してみました。

$ rails destroy scaffold diary

そんでもう一度scafflod

$ rails g scaffold diary title:string body:text
unning via Spring preloader in process 3053
       invoke  active_record
       create    db/migrate/20200109033914_create_diaries.rb
       create    app/models/diary.rb
       invoke    test_unit
       create      test/models/diary_test.rb
       create      test/fixtures/diaries.yml
       invoke  resource_route
        route    resources :diaries
       invoke  scaffold_controller
       create    app/controllers/diaries_controller.rb
       invoke    erb
       create      app/views/diaries
       create      app/views/diaries/index.html.erb
       create      app/views/diaries/edit.html.erb
       create      app/views/diaries/show.html.erb
       create      app/views/diaries/new.html.erb
       create      app/views/diaries/_form.html.erb
       invoke    test_unit
       create      test/controllers/diaries_controller_test.rb
       create      test/system/diaries_test.rb
       invoke    helper
       create      app/helpers/diaries_helper.rb
       invoke      test_unit
       invoke    jbuilder
       create      app/views/diaries/index.json.jbuilder
       create      app/views/diaries/show.json.jbuilder
       create      app/views/diaries/_diary.json.jbuilder
       invoke  assets
       invoke    scss
       create      app/assets/stylesheets/diaries.scss
       invoke  scss
    identical    app/assets/stylesheets/scaffolds.scss

やったね

公開日