Hi,
I currently am using acts as tree for building site navigation. When a
new page is added to the site, a select option with the include blank
option gets populated to determine the correct parent for the new
page. I would like the blank option to be set to 0 for root status.
I tried creating a quick test in the controller to see if the
params[:parent_id] is nil and then assigning a 0 to it but it did not
work. Can anyone offer any help with this?
Thanks!
Shai S. wrote:
Hi,
I currently am using acts as tree for building site navigation. When a
new page is added to the site, a select option with the include blank
option gets populated to determine the correct parent for the new
page. I would like the blank option to be set to 0 for root status.
I tried creating a quick test in the controller to see if the
params[:parent_id] is nil and then assigning a 0 to it but it did not
work. Can anyone offer any help with this?
Thanks!
You can construct the options yourself, and insert the blank option
manually with array addition:
f.select :parent_id, [[’’, 0]] + select_parent_options
Where select_parent_options is a helper like:
def select_parent_options
Page.find(:all).collect do |p|
[p.title, p.id]
end
end
This makes sure that your blank line returns 0 instead of nil.
end
end
Ah ha! Thanks, I was trying this but added the [’’, 0] to the actual
select helper, this helps a ton!