require './config/environment' <% if @options %> class MigrationCheck

def initialize(app)
  @app = app
end

def call(env)
  if ActiveRecord::MigrationContext.new('./db/migrate').needs_migration?
    raise ActiveRecord::PendingMigrationError.new 'Migrations are pending. Run `rake db:migrate` to resolve the issue.'
  end
  @app.call(env)
end

end <% end %> <% unless @options %> # Assets pipeline map ApplicationController.assets_prefix do

run ApplicationController.sprockets

end <% end %> <% if @options %> # Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests. # Read more: github.com/cyu/rack-cors use Rack::Cors do

allow do
  origins '*'
  resource '*', headers: :any, methods: [:get, :post, :patch, :put]
end

end <% end %> run ApplicationController <% if @options %> use MigrationCheck <% end %> ApplicationController.subclasses.each {|klass| use klass }