This won’t be much of a tutorial, but this is a glimpse into my initial attempt to add layers to a drawing app. This is the first time I’ve really thought keeping a state would be useful, so that’s probably the direction I’ll be moving in the future. …

Try it here.

You may have seen articles about using the box-shadow property in CSS to make pixel art. The process involves creating an element with the width and height of a pixel, and creating a box-shadow for each pixel. It looks something like this:

In application.rb, add the following line:

config.generators do |g|
g.orm :active_record, primary_key_type: :uuid

Create a new migration from the command line:

rails g migration enable_uuid

You should get a file that looks like this:

class EnableUuid < ActiveRecord::Migration[6.0]end

Then add this method inside that migration to enable uuid:

class EnableUuid < ActiveRecord::Migration[6.0]
def change
enable_extension 'uuid-ossp'
enable_extension 'pgcrypto'

Finally, in your regular migrations, you can set the id type to uuid:

class CreateUsers < ActiveRecord::Migration[6.0]
def change
create_table :users, id: :uuid do |t|
t.string :username

When you run rails db:migrate, your schema for theUser model should then look like this:

create_table "devices", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.string "username"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false

Tom Cantwell

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store