これはカテゴリモデルです。カテゴリは別のカテゴリに属することができます。親のチェックボックスをアクティブな管理者(フォーマット)にグループ化する方法
class Category < ActiveRecord::Base
attr_accessible :title, :parent_id
has_and_belongs_to_many :products, :join_table => :products_categories
belongs_to :parent, :foreign_key => "parent_id", :class_name => "Category"
has_many :categories, :foreign_key => "parent_id", :class_name => "Category"
end
これは、製品のモデルである:私は階層的に、例えばそのPARENT_IDに基づいてチェックボックスを注文したい製品のアクティブ管理フォームで
class Product < ActiveRecord::Base
attr_accessible :comment, location_id, :category_ids
has_and_belongs_to_many :categories, :join_table => :products_categories
belongs_to :location
end
- カテゴリー1 []
- カテゴリー2 []
- カテゴリー3 []
- カテゴリー6 []
- カテゴリー4 []
- カテゴリ5 []
- カテゴリー7 [] 以下
限り、私は、フォームに持っているようです:
ActiveAdmin.register Product do
form do |f|
f.inputs "Product" do
f.input :comment
f.input :categories, :as => :check_boxes
f.input :location
end
f.buttons
end
end
が現在の形は、チェックボックスに引き出し、正しくデータが保存されますが、私はよく分かりませんそれらをグループ化するところから始めてください。私はドキュメンテーションを見ても、明らかなことは何も見えませんでした。
まれにしか発生して問題になることができないように私には思われます。実際の 'Formtastic :: Inputs :: CheckBoxesInput'基底クラスでこれらの変更をいくつかのテストでhttps://github.com/justinfrench/formtasticにプルリクエストしてもらうことができます。私は時間があるかもしれないが、もし私が自由を見つけることができるまで、おそらく数週間はないだろう。 – jimcavoli