Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,32 @@ $ docker-compose run --rm api rake db:create db:schema:load linksf:import
$ docker-compose run -e STAGING_DB_PASSWORD=<...> --rm api rake db:setup db:import_staging
```

### Developer Tools
#### Rails console
The [Rails console](https://guides.rubyonrails.org/command_line.html#rails-console) gives the developer access to the Rails application

Steps:
1. Navigate to the `askdarcel-api` directory
2. Start both the DB and API
3. Start the Rails console using the following command
```sh
$ docker-compose run --rm api rails console
Copy link
Member

Choose a reason for hiding this comment

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

While I think it's useful to have this here, I'm not sure whether it belongs under a section like this.

The general rule of thumb is for any command that you would normally native run, just prefix it with docker-compose run --rm api.

Also, I wasn't exactly sure what you meant by "ssh into the containers". We don't literally SSH into the containers with ssh, but the closest thing to that is executing a command within the container while attaching your terminal's stdin/stdout. But that is exactly what you are doing here with this command, which seems to conflict with the sentence you wrote at the beginning of the section.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good points. I have updated the wording to be, hopefully, correct and removed the contradictions.

I renamed the section to be Developer Tools; do you think that is a better section have.

```
4. Use the rails console

#### Byebug
[Byebug](https://github.com/deivid-rodriguez/byebug) allows for easy Ruby debugging

Steps:
1. Navigate to the `askdarcel-api` directory
2. Place `byebug` on a new line in the code you want to debug
2. Start both the DB and API
3. Attach a listener to the askdarcel-api docker container using the following command
```sh
$ docker attach $(docker ps -aqf "name=askdarcel-api_api")
```
4. Use the app or postman to call the code of interest. The listener should pause the execution at the `byebug` statement
5. [Debug with byebug](https://www.sitepoint.com/the-ins-and-outs-of-debugging-ruby-with-byebug/)

## macOS-based Development Environment Not Using Docker

Expand Down
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ services:
command: rails server --port=3000 --binding=0.0.0.0
ports:
- "3000:3000"
# Creates a psuedoterminal that connects a user's "terminal" with the stdin and stdout stream
tty: true
# Opens the docker container to input from the terminal
stdin_open: true

postman:
build:
Expand Down