Hi all,
I have a simple Category model which acts_as_tree.
In the form partial, I use a select form helper to display all the
categories so that the user can choose a parent category. This works
fine, but when I submit the form, I get an AssociationTypeMismatch
It seems that the parent id that I pass back into the controller is
being treated as a String, rather than finding the appropriate category
and using that.
I''m using the scaffolding at the moment, so the code looks like:
@category = Category.new(params[:category])
I know that there must be a way of easily assigning all the values in
the params hash, and looking up the correct parent, without labouriously
assigning each value manually ie
@category.name = params[:category][:name]
...
@category.parent = Category.find(params[:category][:parent]
...
...
So any ideas?
Kev