Skip to content

Instantly share code, notes, and snippets.

name: Test
# triggers on
on:
#push:
pull_request:
branches:
- main
jobs:
@GuillaumeOcculy
GuillaumeOcculy / test.yml
Created March 31, 2022 11:03
github action test.yml
name: Test
# triggers on
on:
#push:
pull_request:
branches:
- main
jobs:
@GuillaumeOcculy
GuillaumeOcculy / schema.rb
Created May 23, 2020 12:08
schema_boolean_with_default_value
create_table "users", force: :cascade do |t|
t.string "email", limit: 200, null: false
t.boolean "active", default: true, null: false
end
@GuillaumeOcculy
GuillaumeOcculy / schema.rb
Last active May 23, 2020 11:49
schema_boolean_without_default_value
create_table "users", force: :cascade do |t|
t.string "email", limit: 200, null: false
t.boolean "active"
end
@GuillaumeOcculy
GuillaumeOcculy / generators.rb
Last active March 18, 2020 23:31
generators.rb
# config/initializers/generators.rb
Rails.application.config.generators do |g|
g.orm :active_record, primary_key_type: :uuid
end
@GuillaumeOcculy
GuillaumeOcculy / application_record.rb
Last active March 15, 2020 20:18
application_record.rb
# app/models/application_record.rb
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
# Sort records by date of creation instead of primary key
self.implicit_order_column = :created_at
end
@GuillaumeOcculy
GuillaumeOcculy / create_comment_with_uuid.rb
Last active March 18, 2020 23:41
create_comment_with_uuid.rb
# config/db/migrate/create_comment_with_uuid.rb
class CreateComments < ActiveRecord::Migration[6.0]
def change
create_table :comments, id: :uuid do |t|
t.belongs_to :post, null: false, type: :uuid, foreign_key: true, index: true
t.text :body
t.timestamps
end
@GuillaumeOcculy
GuillaumeOcculy / create_post_with_uuid.rb
Created March 13, 2020 22:06
create_post_with_uuid
# config/db/migrate/create_post_with_uuid.rb
class CreatePosts < ActiveRecord::Migration[6.0]
def change
create_table :posts, id: :uuid do |t|
t.string :title
t.timestamps
end
end
end
# config/db/migrate/enable_uuid.rb
class EnableUuid < ActiveRecord::Migration[6.0]
def change
enable_extension 'pgcrypto'
end
end
{
"data": {
"id": "204",
"type": "movie",
"attributes": {
"id": 204,
"original_title": "Don Quixote"
},
"relationships": {
"cinemas": {