-2

I have two tables items and sub_category and I have has_and_belongs_to_many relation between two. I have to select values for sub categories from different select boxes and include all those values to the item subcategory.

I have a form where I have one drop down box and multiple select box and both these contain sub categories and I have to include the values from both to the item subcategory. How can I do this?

Lundin
  • 195,001
  • 40
  • 254
  • 396
logesh
  • 2,572
  • 4
  • 33
  • 60

2 Answers2

3

This is an example of book and author example.I think you can change this code with your problem.

<%= select_tag "book[author_ids][]", options_from_collection_for_select(Author.all, :id, :name), {:multiple => true, :size => 3} %>
Nithin Viswanathan
  • 3,245
  • 7
  • 39
  • 84
  • This is what i have but with a little change. Instead of select tag i have used collection select but my question is more than one drop down box for the same association and selecting mutiple values from all the drop down. – logesh Mar 19 '13 at 04:30
0

If I have correctly interpretated your question, this example, Rails cast 88, http://railscasts.com/episodes/88-dynamic-select-menus-revised, from rails casts should answer the question. In this example selecting the country then changes the possible slection choice for states. Pierre

user1854802
  • 388
  • 3
  • 14