Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ActiveRecord モデルのすべてのモデル属性と関連付けの配列を取得する方法を探していました。この質問に対する答えを見つけるのに苦労したので、答えを投稿して、より良い解決策があるかどうかを確認します.
私の解決策は次のとおりです。
m = Model.find(id) m.attributes.keys.concat(m.reflections.map{|r| r.first.to_s})