Sis Ccr

Writing custom validation was easy in rails

I had a hotel model and user model. User has many hotels. When creating hotel, I had to validate that it’s email is save as users email associated with it.

class Hotel < ApplicationRecord  validate :check_email?   def check_email…

--

--

Therubyracer in mac Bigsur

Install therubyracer in mac was a pain.

here something worked for me (not in m1 chip though)

brew install v8@3.15
bundle config build.libv8 --with-system-v8
bundle config build.therubyracer --with-v8-dir=$(brew --prefix v8@3.15)
bundle install

--

--

Migrations

Make a field nullable

mix ecto.gen.migration add_nullable_to_field

def change do
alter table(:events) do
modify(:title, :string, null: true, from: :string) # Title column is now nullable
end
end

Add field to existing table

mix ecto.gen.migration add_is_super_admin_to_merchant

Add references to existing table

mix ecto.gen.migration add_district_id_to_room

defmodule Tailwind.Repo.Migrations.AddedDistrictIdToRoom do

--

--