I follows guide at https://github.com/heartcombo/devise
but catch erorr
D:\2024_04_25_rails\vyblog>rails generate scaffold brand brand_name:string company_name:string start_year:integer end_year:integer origin_country:string domestic_country:string invoke active_record create db/migrate/20240508094154_create_brands.rb create app/models/brand.rb invoke test_unit create test/models/brand_test.rb create test/fixtures/brands.yml invoke resource_route route resources :brands invoke scaffold_controller create app/controllers/brands_controller.rb invoke erb create app/views/brands create app/views/brands/index.html.erb create app/views/brands/edit.html.erb create app/views/brands/show.html.erb create app/views/brands/new.html.erb create app/views/brands/_form.html.erb create app/views/brands/_brand.html.erb invoke resource_route invoke test_unit create test/controllers/brands_controller_test.rb create test/system/brands_test.rb invoke helper create app/helpers/brands_helper.rb invoke test_unit invoke jbuilder create app/views/brands/index.json.jbuilder create app/views/brands/show.json.jbuilder create app/views/brands/_brand.json.jbuilderD:\2024_04_25_rails\vyblog>D:\2024_04_25_rails\vyblog>rails server=> Booting Puma=> Rails 7.1.3.2 application starting in development=> Run `bin/rails server --help` for more startup options*** SIGUSR2 not implemented, signal based restart unavailable!*** SIGUSR1 not implemented, signal based restart unavailable!*** SIGHUP not implemented, signal based logs reopening unavailable!Puma starting in single mode...* Puma version: 6.4.2 (ruby 3.2.3-p157) ("The Eagle of Durango")* Min threads: 5* Max threads: 5* Environment: development* PID: 18544* Listening on http://[::1]:3000* Listening on http://127.0.0.1:3000Use Ctrl-C to stopStarted GET "/brand" for ::1 at 2024-05-08 16:42:26 +0700 ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASCActiveRecord::PendingMigrationError (Migrations are pending. To resolve this issue, run: bin/rails db:migrateYou have 1 pending migration:db/migrate/20240508094154_create_brands.rb):activerecord (7.1.3.2) lib/active_record/migration.rb:755:in `check_pending_migrations'activerecord (7.1.3.2) lib/active_record/migration.rb:644:in `block (2 levels) in call'activesupport (7.1.3.2) lib/active_support/file_update_checker.rb:85:in `execute'activerecord (7.1.3.2) lib/active_record/migration.rb:649:in `block in call'activerecord (7.1.3.2) lib/active_record/migration.rb:641:in `synchronize'activerecord (7.1.3.2) lib/active_record/migration.rb:641:in `call'actionpack (7.1.3.2) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'activesupport (7.1.3.2) lib/active_support/callbacks.rb:101:in `run_callbacks'actionpack (7.1.3.2) lib/action_dispatch/middleware/callbacks.rb:28:in `call'actionpack (7.1.3.2) lib/action_dispatch/middleware/executor.rb:14:in `call'actionpack (7.1.3.2) lib/action_dispatch/middleware/actionable_exceptions.rb:16:in `call'actionpack (7.1.3.2) lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'web-console (4.2.1) lib/web_console/middleware.rb:132:in `call_app'web-console (4.2.1) lib/web_console/middleware.rb:28:in `block in call'web-console (4.2.1) lib/web_console/middleware.rb:17:in `catch'web-console (4.2.1) lib/web_console/middleware.rb:17:in `call'actionpack (7.1.3.2) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'railties (7.1.3.2) lib/rails/rack/logger.rb:37:in `call_app'railties (7.1.3.2) lib/rails/rack/logger.rb:24:in `block in call'activesupport (7.1.3.2) lib/active_support/tagged_logging.rb:135:in `block in tagged'activesupport (7.1.3.2) lib/active_support/tagged_logging.rb:39:in `tagged'activesupport (7.1.3.2) lib/active_support/tagged_logging.rb:135:in `tagged'activesupport (7.1.3.2) lib/active_support/broadcast_logger.rb:240:in `method_missing'railties (7.1.3.2) lib/rails/rack/logger.rb:24:in `call'sprockets-rails (3.4.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'actionpack (7.1.3.2) lib/action_dispatch/middleware/remote_ip.rb:92:in `call'actionpack (7.1.3.2) lib/action_dispatch/middleware/request_id.rb:28:in `call'rack (3.0.10) lib/rack/method_override.rb:28:in `call'rack (3.0.10) lib/rack/runtime.rb:24:in `call'activesupport (7.1.3.2) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'actionpack (7.1.3.2) lib/action_dispatch/middleware/server_timing.rb:59:in `block in call'actionpack (7.1.3.2) lib/action_dispatch/middleware/server_timing.rb:24:in `collect_events'actionpack (7.1.3.2) lib/action_dispatch/middleware/server_timing.rb:58:in `call'actionpack (7.1.3.2) lib/action_dispatch/middleware/executor.rb:14:in `call'actionpack (7.1.3.2) lib/action_dispatch/middleware/static.rb:25:in `call'rack (3.0.10) lib/rack/sendfile.rb:114:in `call'actionpack (7.1.3.2) lib/action_dispatch/middleware/host_authorization.rb:141:in `call'railties (7.1.3.2) lib/rails/engine.rb:536:in `call'puma (6.4.2) lib/puma/configuration.rb:272:in `call'puma (6.4.2) lib/puma/request.rb:100:in `block in handle_request'puma (6.4.2) lib/puma/thread_pool.rb:378:in `with_force_shutdown'puma (6.4.2) lib/puma/request.rb:99:in `handle_request'puma (6.4.2) lib/puma/server.rb:464:in `process_client'puma (6.4.2) lib/puma/server.rb:245:in `block in run'puma (6.4.2) lib/puma/thread_pool.rb:155:in `block in spawn_thread'Started GET "/brands" for ::1 at 2024-05-08 16:42:27 +0700 ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASCActiveRecord::PendingMigrationError (Migrations are pending. To resolve this issue, run: bin/rails db:migrateYou have 1 pending migration:db/migrate/20240508094154_create_brands.rb):activerecord (7.1.3.2) lib/active_record/migration.rb:755:in `check_pending_migrations'activerecord (7.1.3.2) lib/active_record/migration.rb:644:in `block (2 levels) in call'activesupport (7.1.3.2) lib/active_support/file_update_checker.rb:85:in `execute'activerecord (7.1.3.2) lib/active_record/migration.rb:649:in `block in call'activerecord (7.1.3.2) lib/active_record/migration.rb:641:in `synchronize'activerecord (7.1.3.2) lib/active_record/migration.rb:641:in `call'actionpack (7.1.3.2) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'activesupport (7.1.3.2) lib/active_support/callbacks.rb:101:in `run_callbacks'actionpack (7.1.3.2) lib/action_dispatch/middleware/callbacks.rb:28:in `call'actionpack (7.1.3.2) lib/action_dispatch/middleware/executor.rb:14:in `call'actionpack (7.1.3.2) lib/action_dispatch/middleware/actionable_exceptions.rb:16:in `call'actionpack (7.1.3.2) lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'web-console (4.2.1) lib/web_console/middleware.rb:132:in `call_app'web-console (4.2.1) lib/web_console/middleware.rb:28:in `block in call'web-console (4.2.1) lib/web_console/middleware.rb:17:in `catch'web-console (4.2.1) lib/web_console/middleware.rb:17:in `call'actionpack (7.1.3.2) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'railties (7.1.3.2) lib/rails/rack/logger.rb:37:in `call_app'railties (7.1.3.2) lib/rails/rack/logger.rb:24:in `block in call'activesupport (7.1.3.2) lib/active_support/tagged_logging.rb:135:in `block in tagged'activesupport (7.1.3.2) lib/active_support/tagged_logging.rb:39:in `tagged'activesupport (7.1.3.2) lib/active_support/tagged_logging.rb:135:in `tagged'activesupport (7.1.3.2) lib/active_support/broadcast_logger.rb:240:in `method_missing'railties (7.1.3.2) lib/rails/rack/logger.rb:24:in `call'sprockets-rails (3.4.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'actionpack (7.1.3.2) lib/action_dispatch/middleware/remote_ip.rb:92:in `call'actionpack (7.1.3.2) lib/action_dispatch/middleware/request_id.rb:28:in `call'rack (3.0.10) lib/rack/method_override.rb:28:in `call'rack (3.0.10) lib/rack/runtime.rb:24:in `call'activesupport (7.1.3.2) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'actionpack (7.1.3.2) lib/action_dispatch/middleware/server_timing.rb:59:in `block in call'actionpack (7.1.3.2) lib/action_dispatch/middleware/server_timing.rb:24:in `collect_events'actionpack (7.1.3.2) lib/action_dispatch/middleware/server_timing.rb:58:in `call'actionpack (7.1.3.2) lib/action_dispatch/middleware/executor.rb:14:in `call'actionpack (7.1.3.2) lib/action_dispatch/middleware/static.rb:25:in `call'rack (3.0.10) lib/rack/sendfile.rb:114:in `call'actionpack (7.1.3.2) lib/action_dispatch/middleware/host_authorization.rb:141:in `call'railties (7.1.3.2) lib/rails/engine.rb:536:in `call'puma (6.4.2) lib/puma/configuration.rb:272:in `call'puma (6.4.2) lib/puma/request.rb:100:in `block in handle_request'puma (6.4.2) lib/puma/thread_pool.rb:378:in `with_force_shutdown'puma (6.4.2) lib/puma/request.rb:99:in `handle_request'puma (6.4.2) lib/puma/server.rb:464:in `process_client'puma (6.4.2) lib/puma/server.rb:245:in `block in run'puma (6.4.2) lib/puma/thread_pool.rb:155:in `block in spawn_thread'Started POST "/rails/actions" for ::1 at 2024-05-08 16:42:28 +0700 ActiveRecord::InternalMetadata Load (0.3ms) SELECT * FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = ? ORDER BY "ar_internal_metadata"."key" ASC LIMIT 1 [[nil, "environment"]] ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASCMigrating to CreateBrands (20240508094154)== 20240508094154 CreateBrands: migrating =====================================-- create_table(:brands) TRANSACTION (0.1ms) begin transaction (2.7ms) CREATE TABLE "brands" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "brand_name" varchar, "company_name" varchar, "start_year" integer, "end_year" integer, "origin_country" varchar, "domestic_country" varchar, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL) -> 0.0059s== 20240508094154 CreateBrands: migrated (0.0074s) ============================ ActiveRecord::SchemaMigration Create (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ('20240508094154') RETURNING "version" TRANSACTION (0.6ms) commit transaction ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASCStarted GET "/brands" for ::1 at 2024-05-08 16:42:28 +0700 ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASCProcessing by BrandsController#index as HTML Rendering layout layouts/application.html.erb Rendering brands/index.html.erb within layouts/application Brand Load (0.1ms) SELECT "brands".* FROM "brands"↳ app/views/brands/index.html.erb:6 Rendered brands/index.html.erb within layouts/application (Duration: 26.0ms | Allocations: 2806) Rendered layout layouts/application.html.erb (Duration: 148.3ms | Allocations: 36505)Completed 200 OK in 222ms (Views: 157.7ms | ActiveRecord: 1.8ms | Allocations: 44772)Started GET "/brands/new?locale=en" for ::1 at 2024-05-08 16:42:30 +0700Processing by BrandsController#new as HTML Parameters: {"locale"=>"en"} Rendering layout layouts/application.html.erb Rendering brands/new.html.erb within layouts/application Rendered brands/_form.html.erb (Duration: 15.4ms | Allocations: 3170) Rendered brands/new.html.erb within layouts/application (Duration: 19.9ms | Allocations: 3482) Rendered layout layouts/application.html.erb (Duration: 27.1ms | Allocations: 4637)Completed 200 OK in 106ms (Views: 28.9ms | ActiveRecord: 0.4ms | Allocations: 18354)Started GET "/brands/new?locale=en" for ::1 at 2024-05-08 16:42:32 +0700Processing by BrandsController#new as HTML Parameters: {"locale"=>"en"} Rendering layout layouts/application.html.erb Rendering brands/new.html.erb within layouts/application Rendered brands/_form.html.erb (Duration: 1.9ms | Allocations: 1447) Rendered brands/new.html.erb within layouts/application (Duration: 2.5ms | Allocations: 1553) Rendered layout layouts/application.html.erb (Duration: 9.1ms | Allocations: 2693)Completed 200 OK in 14ms (Views: 10.2ms | ActiveRecord: 0.0ms | Allocations: 2985)Started POST "/brands?locale=en" for ::1 at 2024-05-08 16:42:55 +0700Processing by BrandsController#create as TURBO_STREAM Parameters: {"authenticity_token"=>"[FILTERED]", "brand"=>{"brand_name"=>"Olym Pianus", "company_name"=>"Olym Pianus", "start_year"=>"2015", "end_year"=>"", "origin_country"=>"China", "domestic_country"=>""}, "commit"=>"Create Brand", "locale"=>"en"} TRANSACTION (0.1ms) begin transaction↳ app/controllers/brands_controller.rb:27:in `block in create' Brand Create (1.6ms) INSERT INTO "brands" ("brand_name", "company_name", "start_year", "end_year", "origin_country", "domestic_country", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING "id" [["brand_name", "Olym Pianus"], ["company_name", "Olym Pianus"], ["start_year", 2015], ["end_year", nil], ["origin_country", "China"], ["domestic_country", ""], ["created_at", "2024-05-08 09:42:56.018075"], ["updated_at", "2024-05-08 09:42:56.018075"]]↳ app/controllers/brands_controller.rb:27:in `block in create' TRANSACTION (0.4ms) commit transaction↳ app/controllers/brands_controller.rb:27:in `block in create'Redirected to http://localhost:3000/brands/1?locale=enCompleted 302 Found in 14ms (ActiveRecord: 2.0ms | Allocations: 3213)Started GET "/brands/1?locale=en" for ::1 at 2024-05-08 16:42:56 +0700Processing by BrandsController#show as TURBO_STREAM Parameters: {"locale"=>"en", "id"=>"1"} Brand Load (0.1ms) SELECT "brands".* FROM "brands" WHERE "brands"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]↳ app/controllers/brands_controller.rb:63:in `set_brand' Rendering layout layouts/application.html.erb Rendering brands/show.html.erb within layouts/application Rendered brands/_brand.html.erb (Duration: 0.8ms | Allocations: 282) Rendered brands/show.html.erb within layouts/application (Duration: 7.7ms | Allocations: 1383) Rendered layout layouts/application.html.erb (Duration: 12.6ms | Allocations: 2519)Completed 200 OK in 145ms (Views: 13.5ms | ActiveRecord: 0.1ms | Allocations: 10967)Started GET "/brands/1/edit?locale=en" for ::1 at 2024-05-08 16:42:57 +0700Processing by BrandsController#edit as HTML Parameters: {"locale"=>"en", "id"=>"1"} Brand Load (0.1ms) SELECT "brands".* FROM "brands" WHERE "brands"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]↳ app/controllers/brands_controller.rb:63:in `set_brand' Rendering layout layouts/application.html.erb Rendering brands/edit.html.erb within layouts/application Rendered brands/_form.html.erb (Duration: 2.6ms | Allocations: 1519) Rendered brands/edit.html.erb within layouts/application (Duration: 4.9ms | Allocations: 1833) Rendered layout layouts/application.html.erb (Duration: 12.5ms | Allocations: 2969)Completed 200 OK in 21ms (Views: 13.5ms | ActiveRecord: 0.1ms | Allocations: 3656)Started GET "/brands/1.json" for ::1 at 2024-05-08 16:43:26 +0700Processing by BrandsController#show as JSON Parameters: {"id"=>"1"} Brand Load (0.2ms) SELECT "brands".* FROM "brands" WHERE "brands"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]↳ app/controllers/brands_controller.rb:63:in `set_brand' Rendering brands/show.json.jbuilder Rendered brands/_brand.json.jbuilder (Duration: 1.4ms | Allocations: 227) Rendered brands/show.json.jbuilder (Duration: 11.3ms | Allocations: 510)Completed 200 OK in 39ms (Views: 25.5ms | ActiveRecord: 0.2ms | Allocations: 1363)- Gracefully stopping, waiting for requests to finish=== puma shutdown: 2024-05-08 16:44:13 +0700 ===- Goodbye!ExitingTerminate batch job (Y/N)?^CD:\2024_04_25_rails\vyblog>rails db:seedbin/rails aborted!NameError: undefined local variable or method `null' for main:Object (NameError)"end_year": null, ^^^^D:/2024_04_25_rails/vyblog/db/seeds.rb:20:in `<main>'Tasks: TOP => db:seed(See full trace by running task with --trace)D:\2024_04_25_rails\vyblog>rails db:migrationUnrecognized command "db:migration" (Rails::Command::UnrecognizedCommandError)Did you mean? db:migrateD:\2024_04_25_rails\vyblog>rails db:migrateD:\2024_04_25_rails\vyblog>rails generate controller Home index create app/controllers/home_controller.rb route get 'home/index' invoke erb create app/views/home create app/views/home/index.html.erb invoke test_unit create test/controllers/home_controller_test.rb invoke helper create app/helpers/home_helper.rb invoke test_unitD:\2024_04_25_rails\vyblog>bundle add deviseFetching gem metadata from https://rubygems.org/.........Resolving dependencies...Fetching gem metadata from https://rubygems.org/.........Resolving dependencies...Fetching orm_adapter 0.5.0Fetching warden 1.2.9Fetching responders 3.1.1Installing orm_adapter 0.5.0Installing warden 1.2.9Installing responders 3.1.1Fetching devise 4.9.4Installing devise 4.9.4D:\2024_04_25_rails\vyblog>rails generate devise:install create config/initializers/devise.rb create config/locales/devise.en.yml===============================================================================Depending on your application's configuration some manual setup may be required: 1. Ensure you have defined default url options in your environments files. Here is an example of default_url_options appropriate for a development environment in config/environments/development.rb: config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } In production, :host should be set to the actual host of your application. * Required for all applications. * 2. Ensure you have defined root_url to *something* in your config/routes.rb. For example: root to: "home#index" * Not required for API-only Applications * 3. Ensure you have flash messages in app/views/layouts/application.html.erb. For example:<p class="notice"><%= notice %></p><p class="alert"><%= alert %></p> * Not required for API-only Applications * 4. You can copy Devise views (for customization) to your app by running: rails g devise:views * Not required *===============================================================================D:\2024_04_25_rails\vyblog>rails g devise:views invoke Devise::Generators::SharedViewsGenerator create app/views/devise/shared create app/views/devise/shared/_error_messages.html.erb create app/views/devise/shared/_links.html.erb invoke form_for create app/views/devise/confirmations create app/views/devise/confirmations/new.html.erb create app/views/devise/passwords create app/views/devise/passwords/edit.html.erb create app/views/devise/passwords/new.html.erb create app/views/devise/registrations create app/views/devise/registrations/edit.html.erb create app/views/devise/registrations/new.html.erb create app/views/devise/sessions create app/views/devise/sessions/new.html.erb create app/views/devise/unlocks create app/views/devise/unlocks/new.html.erb invoke erb create app/views/devise/mailer create app/views/devise/mailer/confirmation_instructions.html.erb create app/views/devise/mailer/email_changed.html.erb create app/views/devise/mailer/password_change.html.erb create app/views/devise/mailer/reset_password_instructions.html.erb create app/views/devise/mailer/unlock_instructions.html.erbD:\2024_04_25_rails\vyblog>rails generate devise MODELRails cannot recover the underscored form from its camelcase form 'MODEL'.Please use an underscored name instead, either 'model' or 'mode_l'.Or setup custom inflection rules for this noun before running the generator in config/initializers/inflections.rb.D:\2024_04_25_rails\vyblog>rails generate devise appuser invoke active_record create db/migrate/20240508104243_devise_create_appusers.rb create app/models/appuser.rb invoke test_unit create test/models/appuser_test.rb create test/fixtures/appusers.yml insert app/models/appuser.rb route devise_for :appusersD:\2024_04_25_rails\vyblog>rails db:migrate== 20240508104243 DeviseCreateAppusers: migrating =============================-- create_table(:appusers) -> 0.0023s-- add_index(:appusers, :email, {:unique=>true}) -> 0.0009s-- add_index(:appusers, :reset_password_token, {:unique=>true}) -> 0.0007s== 20240508104243 DeviseCreateAppusers: migrated (0.0055s) ====================D:\2024_04_25_rails\vyblog>rails generate devise:viewsC:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/activerecord-7.1.3.2/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `before_action' for Appuser:Class (NoMethodError)Did you mean? before_commit from D:/2024_04_25_rails/vyblog/app/models/appuser.rb:7:in `<class:Appuser>' from D:/2024_04_25_rails/vyblog/app/models/appuser.rb:1:in `<main>' from <internal:C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require' from <internal:C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/zeitwerk-2.6.13/lib/zeitwerk/kernel.rb:26:in `require' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/activesupport-7.1.3.2/lib/active_support/inflector/methods.rb:290:in `const_get' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/activesupport-7.1.3.2/lib/active_support/inflector/methods.rb:290:in `constantize' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/activesupport-7.1.3.2/lib/active_support/core_ext/string/inflections.rb:74:in `constantize' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/devise-4.9.4/lib/devise.rb:327:in `get'...D:\2024_04_25_rails\vyblog>
class Appuser < ApplicationRecord # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable before_action :authenticate_user!end
How to fix it?
rails generate controller Home indexbundle add deviserails g devise:viewsrails generate devise appuser