🛤️
【Rails】ActiveHash
作成日:
2022/01/23
0
「ActiveHash」とはRailsのライブラリ(Gem)
変更のないデータ(データベース)をモデルに直接記述して
“ActiveRecord-like”に使うことができる。
GitHub
https://github.com/active-hash/active_hash
例:Model=モデル名,Association=関連付け(has_many :modelsなど)
class (Model) < ActiveHash::Base
self.data = [
{id: 1, key: value1},
{id: 2, key: value2},
{id: 3, key: value3}
]
include ActiveHash::Associations
(Association)
end
AcriveRecordのモデルに関連付け
class Article < ApplicationRecord
extend ActiveHash::Associations::ActiveRecordExtensions
(Association)
end
2021年12月にプログラミングの勉強を始めました!エンジニアになるべくスキルを身に着けたい!