# Problem with select helpers

**URL:** <https://www.ruby-forum.com/t/problem-with-select-helpers/57057>\
**Category:** Rails\
**Created:** [April 6, 2006, 9:29pm UTC](https://www.ruby-forum.com/t/problem-with-select-helpers/57057 "2006-04-06T21:29:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anabia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/35a633/32.png) [@anabia](https://www.ruby-forum.com/u/anabia)\
**Post date:** [April 6, 2006, 9:29pm UTC](https://www.ruby-forum.com/t/problem-with-select-helpers/57057/1 "2006-04-06T21:29:44Z")

</div>

Hi guys,

Im doing a todo list in wich every todo item belongs to a category so at  
the time of create i want a select dropdown to let me choose the  
category for the new todo item.  
I have two models, todo and category(wich contains a name field), all  
goes fine the problem is that i cant fill the select with the names in  
the category table, here are the code im using, i tried many ways to  
make the select work but without success:  
[http://rafb.net/paste/results/ywoI5816.html](http://rafb.net/paste/results/ywoI5816.html)

Hope someone can help with this 🙂

---

<div class="post-metadata">

**Author:** ![anabia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/35a633/32.png) [@anabia](https://www.ruby-forum.com/u/anabia)\
**Post date:** [April 6, 2006, 9:38pm UTC](https://www.ruby-forum.com/t/problem-with-select-helpers/57057/2 "2006-04-06T21:38:38Z")

</div>

Maybe I’m missing something but you never defined the variable  
@categories. Add this line to the list action:

@categories = Category.find(:all, :order =\> “name”)

---

<div class="post-metadata">

**Author:** ![anabia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/35a633/32.png) [@anabia](https://www.ruby-forum.com/u/anabia)\
**Post date:** [April 6, 2006, 9:43pm UTC](https://www.ruby-forum.com/t/problem-with-select-helpers/57057/3 "2006-04-06T21:43:47Z")

</div>

Adam B. wrote:

> Maybe I’m missing something but you never defined the variable  
> @categories. Add this line to the list action:
> 
> @categories = Category.find(:all, :order =\> “name”)

done, i added the @categories = Category.find(:all, :order =\> “name”)  
line to the list action, but now i get this error:

undefined method `name’ for #Array:0x3ab2808

i think the problem its in the select helper sintax because if i use:

 \<% @category.each do |@category| %\> \<%= @category.name %\> \<% end %\>

there are no errors but i want to optimize my code at best.
