Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andyatkinson/bookshop
https://github.com/andyatkinson/bookshop
Last synced: 17 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/andyatkinson/bookshop
- Owner: andyatkinson
- Created: 2024-05-31T15:59:02.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-08-09T19:01:04.000Z (3 months ago)
- Last Synced: 2024-10-10T04:02:46.917Z (about 1 month ago)
- Language: Ruby
- Size: 6.84 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bookshop
I started from Greg Molnar's example, and swapped out SQLite for PostgreSQL.## Postgres
Create the database manually.I'll use the postgres user which is a built-in superuser.
Warning: For real applications, do not use a superuser as the creator (and owner) of your application database. Instead, choose a user with fewer privileges.
```sh
createdb bookshop_development
```## Start Rails Console
```rb
ruby console.rb
```To start over run:
```sh
dropdb --if-exists bookshop_development
```## Active Record
From the [Rails Guide](https://guides.rubyonrails.org/association_basics.html):From a rails console:
```rb
author = Author.create!(first_name: "Jane", last_name: "Doe")
book = author.books.create!(title: "A Cool Book")
```## Dev Containers
A new Rails app "myapp" can be generated using the commands below. The app will be within this repository and exists only to try out generating dev container configuration.This command generates a Rails 7.2 app called "myapp" with PostgreSQL. Configuration will be within the `.devcontainer` directory.
```sh
rails new myapp --database=postgresql --devcontainer
```Once generated, open "myapp" in VS Code either from the application or from your terminal.
To configure command line integration in VS Code, run `Command-Shift-P` (macOS) and choose "Install 'code' command in PATH". Refer to these instructions for more info: [configure your shell](https://code.visualstudio.com/docs/setup/mac).
Once installed in your `PATH`, run `code --version` to verify it's reachable.
With that in place, running `code myapp` will open "myapp" in VS Code. The devcontainers should be auto detected.
Choose "Dev Containers: Rebuild in Container" which launches Docker and all the app dependencies, including PostgreSQL.