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 :) -- Posted via http://www.ruby-forum.com/.
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") -- Posted via http://www.ruby-forum.com/.
Adam Bloom 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: <SELECT NAME="myselect"> <% @category.each do |@category| %> <OPTION VALUE="<%= @category.name %>"><%= @category.name %> <% end %> </SELECT> there are no errors but i want to optimize my code at best. -- Posted via http://www.ruby-forum.com/.