Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-version API helper method lookup error #17

Open
waldofe opened this issue Mar 6, 2017 · 1 comment
Open

Multi-version API helper method lookup error #17

waldofe opened this issue Mar 6, 2017 · 1 comment

Comments

@waldofe
Copy link

waldofe commented Mar 6, 2017

Grape gives the ability to define multi-version API's with fallbacks (i.e. if one hits an endpoint that doesn't exists, it goes up or down a version: version %w(v3 v4), using: :path). Using the array version definition in order to achieve that make it impossible to use grape-route-helpers, which raises NoMethodError: undefined method scan for ['v3', 'v4']:Array in the lookup process.

Steps to reproduce

  1. Define a multi-version Grape API such as version %w(v3 v4), using: :path
  2. Run rake grape:route_helpers

At this point it will raise NoMethodError: undefined method scan for ['v3', 'v4']:Array. I'm not sure if always taking the last element on the array will make sense in every scenario. I'm willing to work on it, any suggestions?

@waldofe
Copy link
Author

waldofe commented Apr 6, 2017

Update: For some reason on tests route_version reaches as a String on the following method:

    def route_versions
      version_pattern = /[^\[",\]\s]+/
      if route_version
        route_version.scan(version_pattern)
      else
        [nil]
      end
    end

While outside tests, route_version is an Array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant