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

Make checkout routes more resource-oriented #272

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

gsmendoza
Copy link
Contributor

@gsmendoza gsmendoza commented Oct 11, 2022

Goal

As a SolidusStarterFrontend user
I want the checkout routes to be converted to resource routes
So that they fit better into Rails conventions.

Background

This is part of an epic to refactor the order and checkout-related controller. Please see https://docs.google.com/spreadsheets/d/1mV2d4H4Ak9kEvc2bxKUpAv4hiz7FwTUE2t-SfOF7g8E/edit?usp=sharing for the list of changes.

Types of changes

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.

@gsmendoza gsmendoza self-assigned this Oct 11, 2022
@@ -0,0 +1,31 @@
# frozen_string_literal: true

module CheckoutHelper
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I intend to convert this to a component in a follow-up PR.


# non-restful checkout stuff
patch '/checkout/update/:state', to: 'checkouts#update', as: :update_checkout
resource :checkout, only: [:edit, :update]
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't be checkouts as we are proposing for carts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the Rails convention for declaring a singular resource. As a singular resource, the paths that the route generates does not have the id param e.g. /checkout instead of checkouts/:id. However, also by Rails convention, the controller mapped to this route maintains a pluralized name (see templates/app/controllers/checkouts_controller.rb).

Copy link
Member

Choose a reason for hiding this comment

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

Ah right, sorry!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hehe.. No worries!

@gsmendoza gsmendoza force-pushed the gsmendoza/sol-477-make-checkout-routes-more-resource branch from 2eb988c to bc23b2d Compare October 12, 2022 08:31
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