Class: SlashMigrate::PendingMigrationCheckProxy

Inherits:
Object
  • Object
show all
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

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, **options)
  @app = app
  @inner = ActiveRecord::Migration::CheckPending.new(app, **options)
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