Multiple options & checkboxes

Hello,

I’m trying to implement a checkbox option function, but I’m having a
problem in visualizing how it needs to be implemented.

Let me explain. I have a model (User) and another model (Category). I
want the user to be able to select multiple categories in the form of
checkboxes and have this information stored in the db.

User habtm Category

and

Category habtm User

But how to implement that as a checkbox listing?? Is this the proper
implmentation of this?

Thanks,
David

Hi David,

David M wrote:

I’m trying to implement a checkbox option function, but I’m
having a problem in visualizing how it needs to be implemented.

Let me explain. I have a model (User) and another model
(Category). I want the user to be able to select multiple
categories in the form of checkboxes and have this information
stored in the db.

One option would be to use check_box_tag and so pretty much avoid the
model
issue all together. Get the values back in the params hash and assign
them
however you like. There are probably much more elegant solutions, but
my
database background is not particularly strong and this is the approach
I’ve
taken on a couple of recent occasions to make progress :wink:

hth,
Bill

I do something similar with User/Roles and a tree of checkboxes, example
on my blog…

http://blog.wolfman.com/articles/2006/05/20/role-based-authentication-admin-page