Class: SlashMigrate::PendingMigrationCheckProxy
- Inherits:
-
Object
- Object
- SlashMigrate::PendingMigrationCheckProxy
- Defined in:
- lib/slash_migrate/pending_migration_check_proxy.rb
Overview
In development Rails inserts ActiveRecord::Migration::CheckPending, which raises PendingMigrationError on every request when an unrun migration exists. Since this engine’s whole job is to create migrations, that check would lock the student out of the very GUI they need to run them.
This proxy replaces CheckPending: it delegates to the real check for the host app’s routes (preserving that safety net everywhere else) but skips it for requests under the engine’s mount path, so the tool stays reachable.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, **options) ⇒ PendingMigrationCheckProxy
constructor
A new instance of PendingMigrationCheckProxy.
Constructor Details
#initialize(app, **options) ⇒ PendingMigrationCheckProxy
Returns a new instance of PendingMigrationCheckProxy.
11 12 13 14 |
# File 'lib/slash_migrate/pending_migration_check_proxy.rb', line 11 def initialize(app, **) @app = app @inner = ActiveRecord::Migration::CheckPending.new(app, **) end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/slash_migrate/pending_migration_check_proxy.rb', line 16 def call(env) if engine_request?(env) @app.call(env) else @inner.call(env) end end |