# Making a custom selection form - newbie

**URL:** <https://www.ruby-forum.com/t/making-a-custom-selection-form-newbie/87372>\
**Category:** Rails\
**Created:** [March 27, 2006, 12:05am UTC](https://www.ruby-forum.com/t/making-a-custom-selection-form-newbie/87372 "2006-03-27T00:05:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adambeazley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5f9b8f/32.png) [@adambeazley](https://www.ruby-forum.com/u/adambeazley)\
**Post date:** [March 27, 2006, 12:05am UTC](https://www.ruby-forum.com/t/making-a-custom-selection-form-newbie/87372/1 "2006-03-27T00:05:46Z")

</div>

Hello all,

I’ve been working with Ruby on Rails for a few weeks now. It’s difficult  
for me because I don’t have much experience with Ruby, Rails, MySQL, or  
any other web-languages. But I’m trudging on and learning a lot.

I’ve been working on a web application for my dad’s website; it’s a  
simple content manager for “listings.” Using the scaffolding and other  
stuff I’ve learned I was able to set up the basic system easily, but the  
categories are not so simple.

Categories are a model: they habtm (has\_and\_belong\_to\_many) listings,  
and listings habtm categories. This way an individual listing can  
display its categories, and a category can display its listings.  
Categories are also trees: each major category contains a variety of  
sub-categories.

The difficult part is creating the UI to create a listing: a listing can  
have one or two main categories, and one or more sub-categories within  
those main categories. The UI needs to be user-friendly, as clients are  
going to be creating the listings.

I’ve tried everything that I’ve learned about FormHelpers, but I don’t  
think they can do what I want. So now I’m assuming that I’m going to  
have to write a bunch of Ruby code that creates a “select” form but more  
complex. I’m hoping to get something that looks like this (only  
prettier, and with meaningful categories):

Categories:

Monkeys  
Lions  
Elephants

Click on Lions, it changes color to indicate selection, and the page  
changes to this:

Monkeys  
Lions  
Taming  
Feeding  
Breeding  
Elephants

Click on a sub-category and it lights up. Send the form (which will also  
include normal text fields) and the selected categories are added to the  
data.

I’m not really looking for code here; I learn a lot when I do things  
myself. What I’m interested is some sort of idea of how to get started,  
what new tools I’ll need to understand, and so on.

---

<div class="post-metadata">

**Author:** ![adambeazley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5f9b8f/32.png) [@adambeazley](https://www.ruby-forum.com/u/adambeazley)\
**Post date:** [March 27, 2006, 9:06pm UTC](https://www.ruby-forum.com/t/making-a-custom-selection-form-newbie/87372/2 "2006-03-27T21:06:37Z")

</div>

Anybody? 🙂

---

<div class="post-metadata">

**Author:** ![adambeazley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5f9b8f/32.png) [@adambeazley](https://www.ruby-forum.com/u/adambeazley)\
**Post date:** [March 27, 2006, 9:46pm UTC](https://www.ruby-forum.com/t/making-a-custom-selection-form-newbie/87372/3 "2006-03-27T21:46:28Z")

</div>

Perhaps you want to look here:

[http://jrhicks.net/Projects/rails/has\_many\_and\_belongs\_to\_many.pdf](http://jrhicks.net/Projects/rails/has_many_and_belongs_to_many.pdf)

> From there, I believe you will be able to determine how best to handle your  
> specific situation.

---

<div class="post-metadata">

**Author:** ![adambeazley](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/5f9b8f/32.png) [@adambeazley](https://www.ruby-forum.com/u/adambeazley)\
**Post date:** [March 28, 2006, 8:39pm UTC](https://www.ruby-forum.com/t/making-a-custom-selection-form-newbie/87372/4 "2006-03-28T20:39:51Z")

</div>

Thanks! I’ll take a look at that.

-Adam
