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

Regex in route scope breaks _path_template methods #12

Open
cavis opened this issue Jul 23, 2018 · 0 comments
Open

Regex in route scope breaks _path_template methods #12

cavis opened this issue Jul 23, 2018 · 0 comments
Labels

Comments

@cavis
Copy link
Member

cavis commented Jul 23, 2018

Adding a constraint to a routes.rb scope breaks the path template helper methods:

scope ':api_version', api_version: /v1|v2/ do

... later

api_story_path_template(api_version: represented.version, id: '{id}')

... throws

ActionController::UrlGenerationError (No route matches {:action=>"show", :api_version=>"_API_VERSION_REPLACE_", :controller=>"api/stories", :id=>"_ID_REPLACE_"} missing required keys: [:api_version]):
  app/representers/api/api_representer.rb:17:in `block in <class:ApiRepresenter>'
  app/controllers/api/api_responder.rb:14:in `api_behavior'
  app/controllers/api/base_controller.rb:35:in `entrypoint'

Appears to be due to how uri_methods.rb replaces the "v1" version string with the placeholder "_API_VERSION_REPLACE_" ... which doesn't match the regex.

@cavis cavis added the bug label Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant