Option for categories

Hi

I need to do options for categories in view

in controller i have action

def new_to_do
@categories = Category.find(:all)
end

new_to_do template contains

Category: <%=options_from_collection_for_select @categories, "id", "category", @item.category_id %>

I get error : You have a nil object when you didn’t expect it!
The error occurred while evaluating nil.category_id

So i have 3 tables categories, items, notes
Items belongs to category and note, so I have add those to the model
of item. Do i have to add category model has_many Items call also?

I appreciate that if sombody could help.

I get error : You have a nil object when you didn’t expect it!
The error occurred while evaluating nil.category_id

You use @item.category_id here without assigning anything to @item, so
it’s nil

So i have 3 tables categories, items, notes
Items belongs to category and note, so I have add those to the model
of item. Do i have to add category model has_many Items call also?

Yes, Category needs a
has_many :items

if Items defined
belongs_to :category

Shouldn’t note belong_to Item instead the other way around?
I just assume this from the name, you may know better.

Yeah. Note belongs to item. Thanks for replay, i have to tried it
tomorrow.