エントリーの編集
エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
記事へのコメント1件
- 注目コメント
- 新着コメント
注目コメント算出アルゴリズムの一部にLINEヤフー株式会社の「建設的コメント順位付けモデルAPI」を使用しています
- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
素のオブジェクトをfields_forに使う - There's an echo in my head
例えばモデル的にGraph has_many Entityだけど、GraphはActiveRecordを使う一方でEntityには素のオブジ... 例えばモデル的にGraph has_many Entityだけど、GraphはActiveRecordを使う一方でEntityには素のオブジェクトを使いたい場合。データストアが異なるとか。 class Graph < ActiveRecord::Base after_save :save_entities def entities @entities ||= [] # TODO: entitiesを読み込む end def entities_attributes=(attributes) # attributes = { "0" => { "name" => "foo", "body" => "bar" }, ... } @entities = attributes.map do |i, (attrs)| Entity.new(attrs) end end private def save
2016/03/30 リンク