Sha256: 95b865fdf57274e3e0059b5d88a5db4f3abd7e1b16fa46c5bd37b21886e70bd7

Contents?: true

Size: 781 Bytes

Versions: 16

Compression:

Stored size: 781 Bytes

Contents

module Flammarion
  module RecognizePath
    def recognize_path(path, options)
      recognized_path = Rails.application.routes.recognize_path(path, options)

    rescue ActionController::RoutingError => e
      unless e.message.start_with? 'No route matches'
        raise e
      end

      Rails::Engine.subclasses.each do |engine|
        mounted_engine = Rails.application.routes.routes.find{ |r| r.app.app == engine }
        next unless mounted_engine

        path_for_engine = path.sub(/^#{mounted_engine.path.spec}/, '')
        begin
          recognized_path = engine.routes.recognize_path(path_for_engine, options)
          break
        rescue ActionController::RoutingError => e
          # do nothing
        end
      end

      recognized_path
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
flammarion_rails-0.3.4 lib/flammarion/recognize_path.rb
flammarion_rails-0.3.3 lib/flammarion/recognize_path.rb
flammarion_rails-0.3.2 lib/flammarion/recognize_path.rb
flammarion_rails-0.3.1 lib/flammarion/recognize_path.rb
flammarion_rails-0.3.0 lib/flammarion/recognize_path.rb
flammarion_rails-0.2.10 lib/flammarion/recognize_path.rb
flammarion_rails-0.2.9 lib/flammarion/recognize_path.rb
flammarion_rails-0.2.8 lib/flammarion/recognize_path.rb
flammarion_rails-0.2.7 lib/flammarion/recognize_path.rb
flammarion_rails-0.2.6 lib/flammarion/recognize_path.rb
flammarion_rails-0.2.5 lib/flammarion/recognize_path.rb
flammarion_rails-0.2.4 lib/flammarion/recognize_path.rb
flammarion_rails-0.2.3 lib/flammarion/recognize_path.rb
flammarion_rails-0.2.2 lib/flammarion/recognize_path.rb
flammarion_rails-0.2.1 lib/flammarion/recognize_path.rb
flammarion_rails-0.2.0 lib/flammarion/recognize_path.rb