I have a rails 3.2
project in which I have Projects
, Categories
, and ProjectCategories
.
A project:
has_many :project_categories
has_many :categories, through: :project_categories
A Category:
has_many :subcategories, class_name: 'Category', foreign_key: 'parent_category_id', dependent: :destroy
belongs_to :parent_category, class_name: 'Category'
has_many :project_categories, dependent: :destroy
has_many :projects, through: :project_categories
A ProjectCategory:
belongs_to :category
belongs_to :project
So a category has n-levels of nesting in it.
I am trying to create a form where the user selects 1 or more top level categories for a project. Based on these selections, the user sees their children categories and can select 1 or more of these. This is repeated until there are no more child levels.
All of these selections are saved as a ProjectCategory
.
Are there any good libraries that will perform something like this?
Has anyone had a similar situation and can recommend a better layout to perform this?
I have looked into ancestry
, awesome_nested_set
and other nested set gems, none if which seems to have any views helpers to accomplish this.
Also rails grouped_collection_select
does not seem to be able to handle this.
Aucun commentaire:
Enregistrer un commentaire