Making a custom selection form - newbie


#1

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.


#2

Anybody? :slight_smile:


#3

Perhaps you want to look here:

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.


#4

Thanks! I’ll take a look at that.

-Adam