Forum: Ruby on Rails Category/subcategory CRUD

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Nando V. (Guest)
on 2005-12-21 21:40
Hello there! This is my first post! ;)
I'm starting on ruby on rails, so I have many doubts about it!

I'm trying to create a system that uses categories/subcategories.
I created a scaffold for a table that has the following fields:

- id int(11)
- name varchar(50)
- keyname varchar(50)
- visible enum('0','1') default '0'
- pid int(11)

The rows are added as:
1, Articles, articles, 1, 0
2, Ruby on Rails, rubyonrails, 1, 1
3, PHP, php, 1, 1
4, FAQ, faq, 1, 0
5, Question 1, q1, 1, 4
6, Question 2, q2, 1, 4

And so on....

The PID field denotes the parent category. So, I have a structure like:

-- Ruby on Rails
-- PHP
-- Question 1
-- Question 2

My question is: I created a scaffold for CRUD the categories. How to add
a SELECT tag populated with all categories that doesn't has the parent
id (pid)?

I want something like:

Name: _________
Keyname: _________
[x] Turn this category visible
Parent category: [------------------]   <= combobox
                 [No parent category]

This topic is locked and can not be replied to.