特定のダッシュボードに表示されるデータセットを決定する一部のモデル間で、has_many :through
の関連付けがあります。has_many throughのチェックボックス、追加の結合テーブル属性を持つ
class Dashboard < ActiveRecord::Base
has_many :dashboard_datasets
has_many :datasets, :through => :dashboard_datasets
end
class DashboardDataaset < ActiveRecord::Base
belongs_to :dashboard
belongs_to :dataset
end
class Dataset < ActiveRecord::Base
has_many :dashboard_datasets
has_many :dashboards, :through => :dashboard_datasets
end
新しいDashboard
を作成するためのフォームは、あなたが、私はそのダッシュボードに表示したい既存のデータセットを選択できるようにするdataset_ids[]
という名前のチェックボックスのシンプルなセットを持っています。
class DashboardForm < Reform::Form
model: :dashboard
property :name
property :description
collection :dataset_ids
end
これまでのところ、とても簡単...
私は今、しかし、のために使用すべきである「レイアウト」を決定するために、結合テーブルに追加の関連付けを追加するために探していますそのダッシュボード上のそのデータセット。グリッド、テーブル、リスト。など
class Layout < ActiveRecord::Base
has_many :dashboard_datasets
end
class DashboardDataaset < ActiveRecord::Base
belongs_to :dashboard
belongs_to :dataset
belongs_to :layout
end
チェックボックスに加えて、選択された各データセットのチェックボックスのために、私はこの与えられた上で、使用するレイアウトを選択するための選択ボックスがあるように私は今、私のダッシュボードの形を適合させたいです協会。
どこから始めますか?フォームオブジェクトのcollection
をより豊かにして、より多くの情報を追加しますか?
大変ありがとうございます。情報の