Skip to content

Commit

Permalink
added write to rails section
Browse files Browse the repository at this point in the history
  • Loading branch information
dunkOnIT committed Sep 21, 2023
1 parent e63a47a commit cd9df16
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 deletions.
Binary file added assets/images/writing_data_react_rails.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 27 additions & 12 deletions contributing/detailed_contributing_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ layout: default
{: .help}
> We could use contributions to add content/clarity to all h1's defined in this article.
# (1) Running the website on your machine
# Running the Website Locally

## (1) Running the website on your machine

This is an essential step of contributing to the WCA website, as you'll want to see the effect of the changes you make to the code.

## 1. Clone this repo! (And navigate into it)
### 1. Clone this repo! (And navigate into it)
1. `git clone https://github.com/thewca/worldcubeassociation.org`
2. `cd worldcubeassociation.org`

## 2. Run using Docker
### 2. Run using Docker

1. Install [Docker](https://docs.docker.com/get-docker/) (remember to complete the [Linux post-install steps](https://docs.docker.com/engine/install/linux-postinstall/) if you're on Linux)
2. Install docker-compose. The best way to get an up-to-date version is to get it from their [releases page](https://github.com/docker/compose/releases)
Expand All @@ -24,25 +26,38 @@ This is an essential step of contributing to the WCA website, as you'll want to
5. To run tests, run `docker-compose exec wca_on_rails bash -c "RAILS_ENV=test bin/rake db:reset && RAILS_ENV=test bin/rake assets:precompile && bin/rspec"`
6. If you're using Visual Studio Code to develop, you can [attach it to the Docker container](https://code.visualstudio.com/docs/remote/containers) so that your extensions can take advantage of the Ruby environment and so the terminal runs from inside the container

## 3. Set up the database
### 3. Set up the database
TODO

## 4. Run migrations (if necesary)
### 4. Run migrations (if necesary)

# (2) Find an issue you'd like to contribute to
## (2) Find an issue you'd like to contribute to

You can look at our [good first issues](), find one that interests you, and add a comment saying that you'd like to work on the issue.

# (3) Create a new branch, and start writing your changes.

## Create a new branch
## (3) Create a new branch, and start writing your changes.

### Create a new branch

## Start the Docker container
### Start the Docker container

## Start writing your code
### Start writing your code

With the Docker container running, the website will automatically update with any changes you make to the code.

# (4) Commit and push your changes
## (4) Commit and push your changes

# Opening A Pull Request

# Reviewing Someone's Pull Request

# (5) When you're ready, open a PR (or start with a draft)
# Pulling from / Pushing to Someone's Pull Request

- Pulling: `gh pr checkout {pr-number}`
- Pushing: `git push [email protected]:{author-username}@worldcubeassociation.org.git HEAD:{branch-name}`

The "pushing" command allows you to push changes to someone's repo without adding them as REMOTE on your local git.

{: .help}
> Add instructions for pushing to a repo by adding it as remote and then pushing to it
11 changes: 9 additions & 2 deletions guides/passing_data_react_rails.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,17 @@ If `serializable_hash` doesn't produce data in the format you require, you shoul

# Writing data to Rails

{: .info}
> Diagrams in this section are available for editing to WST members [here](https://app.diagrams.net/#G1V1mXsYcMw6cIaPJU3cA-s3pJ7psYovLD#%7B%22pageId%22%3A%22wrVvO56TNKLfE-PIFfzB%22%7D).
As seen below, writing data to Rails is very similar to the best practice for reading data from Rails. Essentially, **the Rails backend exposes an API endpoint which the React frontend can make POST/PATCH calls to.**

## Option 1: API Communication
![](/assets/images/writing_data_react_rails.png)

## Option 2: Serializing Rails data
The process of finding an API endpoint to write data to is the same as the previous section:
- Check if the endpoint already exists
- If yes, modify it if necessary and make use of it
- If no, create one (see "Create a new endpoint" for details)

----

Expand Down

0 comments on commit cd9df16

Please sign in to comment.