# rendering advice for has\_and\_belongs\_to\_many relationship?

**URL:** <https://discuss.rubyonrails.org/t/rendering-advice-for-has-and-belongs-to-many-relationship/5976>\
**Category:** rubyonrails-talk\
**Created:** [December 17, 2006, 9:34pm UTC](https://discuss.rubyonrails.org/t/rendering-advice-for-has-and-belongs-to-many-relationship/5976 "2006-12-17T21:34:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![David19](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@David19](https://discuss.rubyonrails.org/u/David19)\
**Post date:** [December 17, 2006, 9:34pm UTC](https://discuss.rubyonrails.org/t/rendering-advice-for-has-and-belongs-to-many-relationship/5976/1 "2006-12-17T21:34:09Z")

</div>

I am working on a time tracking app; you have users and projects, and users can be included as part of a project.

This shows itself in the UI of the site in two ways. The first, that users can only choose to record time against projects they are a part of, was pretty simple to add.

However the second change to the site, that administrators creating and editing projects can choose which users have access, seems like I'm writing too much code. On the project add/edit form, I want to have a list of all users with checkboxes to set who has access. I think the thing that is getting me is that the has\_and\_belongs\_to\_many methods do not allow me to get a list of say every project and a boolean showing if there is a relationship, or use such a list to update the database records.

Data model subset: CREATE TABLE projects ("id" INTEGER PRIMARY KEY NOT NULL, "name" varchar(255)); CREATE TABLE projects\_users ("id" INTEGER PRIMARY KEY NOT NULL, "user\_id" integer NOT NULL, "project\_id" integer NOT NULL); CREATE TABLE users ("id" INTEGER PRIMARY KEY NOT NULL, "name" varchar(255), "hashed\_password" varchar(255), "salt" varchar(255), "admin" boolean DEFAULT 0 NOT NULL);

-DW
