Chouti,

To solve your first issue, I would set up your models slightly
different.

class Item < ActiveRecord::Base
  belongs_to :sub_category
end

class SubCategory < ActiveRecord::Base
  belongs_to :category
  has_many :items
end

class Category < ActiveRecord::Base
  has_many :sub_categories
  has_many :items, :through => :sub_categories
end

in your items controller you can do this
  active_scaffold do |config|
    config.columns[:sub_category].form_ui = :select
  end

This changes it from a subform, and now you only have one drop down
that is visible, and there will no longer be options to create
subcategories.
This does not solve your problem with the form though.  There are many
ways to approach getting a category drop down, and then making it work
with javascript.  If you would like help with this let me know.
-Yairgo
On Jan 8, 5:41 pm, chouti <[email protected]> wrote:
> Hi Yarigo
>
> Thank you for your help.
> According to your question, no, model can not have a category without
> a subcategory, and can not have a subcategory without a category
> either.
>
> On Jan 9, 1:51 am, yairgo <[email protected]> wrote:
>
> > Addressing your first question,
>
> > the model Item belongs to category and subcategory.
> > 1.  Is Item allowed to have a subcategory without having a category?
> > 2.  Can Item have a category without having a subcategory?
>
> > It would be possible to make 2 select drop downs, one for category and
> > one with subcategory and have it change the values in subcategory when
> > you change category..
> > I can help you address this issue once I have answers to the above.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to