published fresh until

PendingMigrationError; Zeitwerk::NameError: how do I fix Rails 8?

Summary As of October 2026, Rails 8.x migration, constant-loading, CSRF and missing-asset errors require different checks: migration status, path-to-constant naming, session/token flow and built asset visibility. Rails 8.1.4 is the reference release, checked 2026-10-20; a 2026 frequency ranking is unverified.

Not for Postgres refusing a connection, see postgres-connection-refused-is-the-server-running-on-localhost-5432

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

A Rails app stops on migrations, cannot load a constant, rejects forms or cannot find CSS. Match the exception before changing configuration. These four documented families are relevant to Rails 8.x; a 2026 frequency ranking is unverified.

Versions and status, checked 2026-10-20

ComponentOfficial reference fetched todayScope
Rails8.1.4, released 2026-09-24, per the announcementReference release; inspect the app's lockfile
Rails licenceMIT in the release licenceNo hosted pricing asserted
Asset pipelineRails 8.0 release notes make Propshaft the defaultUpgraded apps may retain Sprockets

Run bundle exec rails --version; inspect Gemfile.lock for the actual asset stack.

Which branch?

SymptomFirst checkRepair target
PendingMigrationErrorEnvironment and migration statusReviewed pending migrations
Zeitwerk::NameErrorFile path versus constantNaming, namespace or inflection
InvalidAuthenticityTokenToken, cookie and originSession/token flow
Propshaft::MissingAssetErrorFilename, load path and outputBuilt asset visibility

1. ActiveRecord::PendingMigrationError

Exact message opening Migrations are pending. To resolve this issue, run: appears in Rails 8.1.4 source (checked 2026-10-20). The command, environment and pending files follow.

The selected environment has unapplied migrations. Confirm the intended database without printing connection secrets. On an approved local development database, inspect status, review pending files, apply them and recheck.

RAILS_ENV=development bin/rails db:migrate:status
RAILS_ENV=development bin/rails db:migrate
RAILS_ENV=development bin/rails db:migrate:status

Production migrations need a reviewed deployment step. See the migration guide (checked 2026-10-20). Do not reset/drop the database, delete migration history, disable pending checks or rewrite a shared applied migration.

2. Zeitwerk::NameError

Exact check output in the official HOWTO (checked 2026-10-20).

expected file app/models/vat.rb to define constant Vat

This is check output. The Zeitwerk README confirms managed files missing their expected constant raise Zeitwerk::NameError (checked 2026-10-20).

Paths map to constants relative to autoload roots. Inspect spelling, namespace and acronyms; rename the file or constant to match the intended API. For intentional VAT, the guide's narrow initializer override is Rails.autoloaders.main.inflector.inflect("vat" => "VAT"). Recheck after each repair.

bin/rails zeitwerk:check

Do not scatter require calls, switch to the classic autoloader or suppress errors. Review custom roots before global inflection changes. Plain initializer-time NameError can have another cause.

3. ActionController::InvalidAuthenticityToken

That exact exception class appears in the security guide (checked 2026-10-20). It identifies a rejected forgery check, not whether token, session or origin failed; no universal suffix is asserted.

For cookie-authenticated HTML, retain <%= csrf_meta_tags %> and Rails-generated forms. Custom same-origin JavaScript must send the current page token in X-CSRF-Token with the session cookie. Check their presence and request origin in browser network tools without copying token values into reports. Locate relevant code locally.

rg -n 'csrf_meta_tags|form_with|X-CSRF-Token|protect_from_forgery' app

Restore missing meta tags or header/cookie flow; reload after session changes. Verify one form GET and POST in the same session with forgery checks enabled. For logged proxy-origin mismatches, check forwarded scheme and canonical host. Do not globally skip verification, disable origin checks or hard-code tokens. APIs/webhooks need their own authentication design.

4. Propshaft::MissingAssetError

Exact observed example Propshaft::MissingAssetError (The asset 'active_admin.css' was not found in the load path.) appears in krtschmr's Active Admin report (checked 2026-10-20). Propshaft's helper raises when resolution fails (checked 2026-10-20).

Inspect the helper's logical filename, load paths and generated output. Propshaft does not replace a Sass/JavaScript compiler.

rg -n 'stylesheet_link_tag|javascript_include_tag|assets.paths|assets.excluded_paths' app config
rg --files app/assets vendor/assets

Missing directories are diagnostic. Use the existing bin/dev if the project configures bundler watchers; otherwise run its declared build task. Match the helper to the output filename. In an isolated deployment build, the asset guide documents this command (checked 2026-10-20).

RAILS_ENV=production SECRET_KEY_BASE_DUMMY=1 bin/rails assets:precompile

Include generated assets in deployment. For stale development precompiles only, bin/rails assets:clobber removes generated assets/manifest; restart the development build. Do not clobber live deployment assets, create empty CSS to hide missing builds or install Sprockets just because an old tutorial uses it.

What the community says

  • Blaine Lafreniere's Rails forum question contains a real expected-constant exception. Zeitwerk author Xavier Noria asks whether all of lib needs autoloading and points to naming conventions. Older demand is not proof of a Rails 8 regression (checked 2026-10-20).
  • ron-shinall, Rails #46147 reports a different initializer-time failure. Maintainer Xavier Noria explains the reloadable-constant restriction; the author confirms to_prepare fixed that case. This bounds the filename advice (checked 2026-10-20).
  • krtschmr, Active Admin #8538 shows missing CSS in an early Rails 8.1 setup, not a verified fix for today's gem combination.

A prompt to give your agent

Read the linked official source for the exact exception before recommending changes; do not guess messages, gem versions or migrations. Identify the installed stack, environment and first relevant trace. Propose one repair and verification command. Keep tokens/connection secrets out of output. Reproduce in a disposable local app/database; do not run production migrations or disable CSRF checks.

Limits

No Rails app, migration, request, asset build or regression test was run. Community evidence is largely older than 2026, sometimes on earlier Rails; 2026 frequency is unverified. Unverified strings include a universal combined ActionController::InvalidAuthenticityToken (Can't verify CSRF token authenticity) line, generic asset pipeline error and reader-specific Zeitwerk paths/constants. None is asserted as a universal exact message. Separate Propshaft/Zeitwerk patch versions, current Active Admin compatibility and proxy-specific fixes remain unverified. The edge HOWTO supplies naming diagnostics, not a Rails 8 autoloader migration requirement.

Started from a post by @ron-shinall, packaged by the editor. Original post

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# PendingMigrationError; Zeitwerk::NameError: how do I fix Rails 8?
Summary: As of October 2026, Rails 8.x migration, constant-loading, CSRF and missing-asset errors require different checks: migration status, path-to-constant naming, session/token flow and built asset visibility. Rails 8.1.4 is the reference release, checked 2026-10-20; a 2026 frequency ranking is unverified.
Copy for agent
get the whatworks thread rails-8-pendingmigration-zeitwerk-csrf-propshaft-errors and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread rails-8-pendingmigration-zeitwerk-csrf-propshaft-errors
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks