{"record":{"id":"17dfee3789130b64","repo":"heartcombo/devise","slug":"an-orm-must-be-set-to-install-devise-in-your-appli","errorCode":null,"errorMessage":"An ORM must be set to install Devise in your application.\n\nBe sure to have an ORM like Active Record or Mongoid loaded in your\napp or configure your own at `config/application.rb`.\n\n  config.generators do |g|\n    g.orm :your_orm_gem\n  end","messagePattern":"An ORM must be set to install Devise in your application\\.\n\nBe sure to have an ORM like Active Record or Mongoid loaded in your\napp or configure your own at `config/application\\.rb`\\.\n\n  config\\.generators do \\|g\\|\n    g\\.orm :your_orm_gem\n  end","errorType":"exception","errorClass":"Devise::Generators::MissingORMError","httpStatus":null,"severity":"error","filePath":"lib/generators/devise/install_generator.rb","lineNumber":18,"sourceCode":"# frozen_string_literal: true\n\nrequire 'rails/generators/base'\nrequire 'securerandom'\n\nmodule Devise\n  module Generators\n    MissingORMError = Class.new(Thor::Error)\n\n    class InstallGenerator < Rails::Generators::Base\n      source_root File.expand_path(\"../../templates\", __FILE__)\n\n      desc \"Creates a Devise initializer and copy locale files to your application.\"\n      class_option :orm, required: true\n\n      def copy_initializer\n        unless options[:orm]\n          raise MissingORMError, <<-ERROR.strip_heredoc\n          An ORM must be set to install Devise in your application.\n\n          Be sure to have an ORM like Active Record or Mongoid loaded in your\n          app or configure your own at `config/application.rb`.\n\n            config.generators do |g|\n              g.orm :your_orm_gem\n            end\n          ERROR\n        end\n\n        template \"devise.rb\", \"config/initializers/devise.rb\"\n      end\n\n      def copy_locale\n        copy_file \"../../../config/locales/en.yml\", \"config/locales/devise.en.yml\"\n      end\n","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/heartcombo/devise/blob/372b295fe6f63b4af3269f5dcd51a18c0bc2016c/lib/generators/devise/install_generator.rb#L1-L36","documentation":"The devise:install generator (rails generate devise:install) needs an ORM to later create models and migrations, and Rails feeds the configured ORM into the generator through the required orm class_option (set from config.generators, g.orm). When no ORM is configured — typically an app generated with --skip-active-record where no replacement like Mongoid was wired into generators — copy_initializer raises MissingORMError (a Thor::Error) telling you to set g.orm in config/application.rb. It is a setup-time guard, not a runtime failure.","triggerScenarios":"Running rails generate devise:install in a Rails app created with --skip-active-record before adding config.generators { |g| g.orm :mongoid }; using Devise with MongoMapper/DataMapper-era or custom ORMs without generator config; the ORM gem is in the Gemfile but config/application.rb was never told about it, so Rails' generator framework passes a nil orm option.","commonSituations":"Adding Devise to a Mongoid app (most common non-AR pairing) and forgetting the generators block; API-only or minimal apps with Active Record stripped; CI scaffolding scripts that run devise:install before application.rb is fully set up.","solutions":["If you intend to use Mongoid: add gem \"mongoid\" to the Gemfile, bundle, and add to config/application.rb inside the Application class: config.generators do |g| g.orm :mongoid end — then re-run rails generate devise:install.","If you want Active Record after all: ensure railties/active_record are not skipped (config.database.yml present, no --skip-active-record) and re-run the generator.","For any other ORM adapter, register it the same way via config.generators do |g| g.orm :your_orm_gem end per the adapter's README, then re-run.","Restart any spring/bootsnap-cached processes after editing config/application.rb so the generator sees the new setting."],"exampleFix":"# before (config/application.rb, app generated with --skip-active-record)\nmodule MyApi\n  class Application < Rails::Application\n    # no generators config -> devise:install raises MissingORMError\n  end\nend\n\n# after (Gemfile)\ngem \"mongoid\", \"~> 8.0\"\n\n# config/application.rb\nmodule MyApi\n  class Application < Rails::Application\n    config.generators do |g|\n      g.orm :mongoid\n    end\n  end\nend\n\n# then re-run\n# rails generate devise:install","handlingStrategy":"validation","validationCode":"# Check ORM generator config before invoking the generator:\ndef orm_configured?\n  Rails.application.config.generators.options.dig(:rails, :orm).present?\nend\n\nraise \"Configure config.generators { |g| g.orm :mongoid } first\" unless orm_configured?\n# safe to run: rails generate devise:install","typeGuard":"def orm_configured?\n  Rails.application.config.generators.options.dig(:rails, :orm).present?\nend","tryCatchPattern":null,"preventionTips":["In --skip-active-record apps, add the generators block (config.generators { |g| g.orm :mongoid }) before running any devise generators.","Put the ORM gem above devise in the Gemfile so it loads first, and verify with rails runner 'puts Rails.application.config.generators.options[:rails][:orm]'.","Re-run rails generate devise:install after fixing config/application.rb — the check happens per-generator-run, no migration cleanup needed.","Stop spring/bootsnap-cached environments after config changes so the generator reads fresh settings."],"tags":["devise","rails","generator","orm","setup","mongoid"],"backgroundTag":"missing-orm-configuration","analyzedSha":"372b295fe6f63b4af3269f5dcd51a18c0bc2016c","analyzedAt":"2026-08-21T11:55:31.116Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}