You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way to set the default version just for one route/controller action?
I want to use the latest version available for all api resources except one. For this resource, I would like it to use version 1 of the api unless a specific api version is specified.
Let me know if you need more information to understand my question. Overriding the default_version config works for the time being, but I would like to implement this in a way that going forward it might work for multiple resources.
The text was updated successfully, but these errors were encountered:
Interesting use case! I don't see an easy way to support this now, but can think of a couple ways to go about this:
before_actions
classPostsController < ApplicationControllerprepend_before_action:override_latest_version,only: :show,if: :'request_version_missing?'# this API doesn't exist yetdefindex;enddefshow;endprivatedefoverride_latest_versionset_version1endend
configuration
VersionCake.setupdo |config|
config.resourcesdo |r|
r.resource%r{.*},[],[],(1..4),1# overrides the global missing_versionendconfig.extraction_strategy=:query_parameter# for simplicityconfig.missing_version=4end
I think I prefer the second method to the prepend_before_filter option. It would allow for all Versioncake configuration to stay together, rather than having to add extra things to a controller.
Is there a way to set the default version just for one route/controller action?
I want to use the latest version available for all api resources except one. For this resource, I would like it to use version 1 of the api unless a specific api version is specified.
Let me know if you need more information to understand my question. Overriding the
default_version
config works for the time being, but I would like to implement this in a way that going forward it might work for multiple resources.The text was updated successfully, but these errors were encountered: