# ActiveScaffold dropdown column value from other table

**URL:** <https://www.ruby-forum.com/t/activescaffold-dropdown-column-value-from-other-table/126545>\
**Category:** Rails\
**Created:** [January 19, 2008, 9:42am UTC](https://www.ruby-forum.com/t/activescaffold-dropdown-column-value-from-other-table/126545 "2008-01-19T09:42:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnlester](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@johnlester](https://www.ruby-forum.com/u/johnlester)\
**Post date:** [January 19, 2008, 9:42am UTC](https://www.ruby-forum.com/t/activescaffold-dropdown-column-value-from-other-table/126545/1 "2008-01-19T09:42:23Z")

</div>

Aplogies for posting a question which I think must be trivial but I  
can not find the answer anywhere!

I have posted this to the ActiveScaffold forum but there seems to be  
very little activity there, hopefully there is someone here willing to  
help ?

I have two tables, Item and Category. Item belongs\_to Category which  
has\_many Items. I am trying to code up an Item form where one of the  
fields allows selection of a category.

My ItemController looks like this:

class ItemController \< ApplicationController  
active\_scaffold :item do |config|  
columns[:category].ui\_type = :select  
end  
end

which makes the “category” field appear as a drop-down list.

My ItemHelper looks like this:

module ItemHelper  
def category\_column(record)  
if record.category.nil?  
“”  
else  
record.category.summary  
end  
end

def category\_form\_column(record,input\_name)  
options = Category.find(:all).collect do |c|  
[c.summary, c.id]  
end  
select :record, :category, options, {:include\_blank =\>  
false, :prefix =\> input\_name}  
end  
end

The category\_form\_column helper makes the correct category names  
appear in the drop down.

The form is correctly rendered but when I commit, the record shows a  
nil category\_id and a nil @category.

What am I missing ? I’ve looked everywhere for an example but can’t  
find one. I think an ActiveScaffold tutorial on this would be useful.

Thanks for any help…
