Skip to content

Instantly share code, notes, and snippets.

@robertorodriguez12
Last active October 28, 2021 20:47
Show Gist options
  • Save robertorodriguez12/1051778831e45a6a869e54eef8ac9732 to your computer and use it in GitHub Desktop.
Save robertorodriguez12/1051778831e45a6a869e54eef8ac9732 to your computer and use it in GitHub Desktop.
Steps to run checkout gem locally with estores app

Steps for running checkout gem on your local with dockerized estores application

Steps to get file path

  1. Clone the Checkout repository to your machine

    • Pull down from the main branch
  2. Using a terminal outside of VS Code, navigate to the checkout repository

    • Once inside the checkout repository, type pwd and press enter to get the file path (copy and paste the path into a note for use later)

    • Example of what the path looks like: /Users/robertorodriguez/kotis/checkout

In Checkout

  1. Create a new branch off of main this will allow estores to find the correct version of the gem.

  2. Add return {} as the first line under def validate_from_api inside of address_validator.rb.

    • This allows you to avoid error messages when checkout tries to validate the entered shipping address.

In Estores

Note: Do not commit / push up changes made to your docker-compoese.yml file

  1. In the docker-compose.yml (not the one in the .devcontainer folder)

    • Add a new line to volumes under app. In this new line you will add the file path you copied earlier, at the end of the file path add a : followed by /checkout so that your file path looks like the one in the screenshot below.
Screenshot of docker-compose.yml with new line added

Screen Shot 2021-10-15 at 11 10 49

  1. Rebuild your docker container

  2. Go to your gemfile

  3. Comment out gem 'kotis-checkout', '~> <current version number>'

  4. Add

    gem 'kotis-checkout', '~> <current version number>',
                               git: 'checkout/checkout',
                               branch: '<branch name you created in checkout>'
  5. In the terminal within VSCode run the following commands

    • bundle config local.kotis-checkout /checkout
    • Run bundle install
    • Run your server

Verifying that it works

  1. In checkout you can add a <div> element with a string into app/views/layouts/kotis/checkout/application.html.erb

    <div> Hello Kotis </div>
  2. Using your localhost server, visit an estores portal, add a few items to your shopping cart then press checkout. If you see the string you added to the view in checkout then you are connected and ready to go.

@ilynne
Copy link

ilynne commented Oct 27, 2021

Here's what I did with docker-compose.yml:

    volumes:
      - .:/app
      - node_modules:/app/node_modules
      - bundle_path:/bundle
      - ${CHECKOUT_PATH}:/checkout

.env file:

DATABASE_USER=
DATABASE_PASSWORD=
DATABASE_NAME=
DATABASE_HOST=
REDIS_HOST=
CHECKOUT_PATH=/Users/robertorodriguez/kotis/checkout

With this setup, we could push the docker-compose.yml change to GitHub, because the actual path remains local. But don't do that at this time.

@robertorodriguez12
Copy link
Author

@ilynne, thank you for sharing this :), with the above changes, would the bundle config local.kotis-checkout /checkout command stay the same? Or would it be adjusted to something else?

@ilynne
Copy link

ilynne commented Oct 28, 2021

It would stay the same. We moved the path to a variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment