Hi all,
I am having an issue here that i seem not to wrap my head around… I am
making a simple online catalog…
I have 2 models Category and LineItems
where Category has many LineItems
So in the LineItem Model I say:
class LineItem < ActiveRecord::Base
belongs_to :category
Now in my edit form (View) for LineItem called edit.rhtml, with a drop
down list, I wish to select the category and update it in the database.
For that I use the following before the scaffolding code in the (this is
a simple test app I am doing here…).
<%=
@categories = Category.find(:all, :order => “name”).map {|c| [c.name,
c.id]}
select(:category, :id, @categories)
%>
Items come up ok but I cannot seem to update. I believe the select
parameters are ok but could the problem be there or am I missing
something ?
Note that when I use the Edit view, I wish to read the existing
category_id and have it pre-selected for me if it already exists.
TIA,
Tuka