Habtm and multiple-option select boxes

I’ve got a fairly basic has_and_belongs_to_many setup, with a Business
model and a Category model. In the admin functionality for the
I’d like to have a multiple select box showing all of the Categories,
included ones selected, etc.

I’m stumped as to how to do it, though - it seems like there should be
easy way, but I’m missing it looking over the docs. I can’t do the

select(“business”, “category_id”, Category.find_all.collect {|c|
[c.name, c.id ] }, { :include_blank => true })

Because there’s no business.category_id due to the HABTM.

What’s the standard way to accomplish this?


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs