Skip to content

path option is now used when generating url paths#959

Open
beniutek wants to merge 1 commit intoJSONAPI-Resources:masterfrom
beniutek:add-path-option-to-routes
Open

path option is now used when generating url paths#959
beniutek wants to merge 1 commit intoJSONAPI-Resources:masterfrom
beniutek:add-path-option-to-routes

Conversation

@beniutek
Copy link
Copy Markdown

previously when generating routes in rails app and using path option like this:

jsonapi_resources users, path: 'members'

the generated routes from rake routes:

          POST /users   /users#create
users GET   /users   /users#index
etc

now when we specify this option

          POST /members /users/#create
users GET   /members /users#index
etc

helpers stay the same, only url path changes

if path option is not specified or is nil then routes generated make use of the @resource_type as before

I was under impression that we want to generate and handle routes in similar fashon as in

http://guides.rubyonrails.org/routing.html#translated-paths

that's why im making this change

options[:controller] ||= @resource_type
options.merge!(res.routing_resource_options)
options[:path] = format_route(@resource_type)
options[:path] = format_route(options[:path] || @resource_type)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if :path options is not set in routes.rb, it takes the @resource_type to formatter to form the name for the path

@kbroderick
Copy link
Copy Markdown

Any chance of this getting merged in? I would find this useful so that we can abstract out some of the class-structure details in our project that we hope to refactor in the future.

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

Successfully merging this pull request may close these issues.

2 participants