# Has\_and\_belongs\_to\_many with default

**URL:** <https://www.ruby-forum.com/t/has-and-belongs-to-many-with-default/174532>\
**Category:** Rails\
**Created:** [August 28, 2009, 9:43am UTC](https://www.ruby-forum.com/t/has-and-belongs-to-many-with-default/174532 "2009-08-28T09:43:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aldoitalo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@aldoitalo](https://www.ruby-forum.com/u/aldoitalo)\
**Post date:** [August 28, 2009, 9:43am UTC](https://www.ruby-forum.com/t/has-and-belongs-to-many-with-default/174532/1 "2009-08-28T09:43:42Z")

</div>

hi,  
i have used a relaction has\_and\_belongs\_to\_many to implementing a  
backoffice where the customer settings categories and products: the  
products can have multiple categories, it selet them with a combobox.  
Now the problem is the customer ask me needly to choice a category by  
default: products are indicizated on google, when this links are opening  
the product must by reporting the default category.  
how i obtain this with an has\_and\_belongs\_to\_many relaction?
