Giter VIP home page Giter VIP logo

bookshop's Introduction

Bookshop

I started from Greg Molnar's example, and swapped out SQLite for PostgreSQL. https://greg.molnar.io/blog/a-single-file-rails-application/

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.

createdb bookshop_development

Start Rails Console

ruby console.rb

To start over run:

dropdb --if-exists bookshop_development

Active Record

From the Rails Guide:

From a rails console:

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.

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.

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.

bookshop's People

Contributors

andyatkinson avatar

Stargazers

Gray Kemmey avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.