Problem with select helpers

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

Hope someone can help with this :slight_smile:

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”)

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.