Turn an acts_as_tree structure into a select drop-down.

This is probably the easiest way to turn Rails’ acts_as_tree structure into a select field:
HTML:

<select name="category_id">
<%= expand_tree_into_select_field(Category.top) %>
</select>

Ruby helper:

def expand_tree_into_select_field(categories)
returning(String.new) do |html|
categories.each do |category|
html << %{<option value="#{ category.id }">#{ ‘&nbsp;&nbsp;&nbsp;’ * category.ancestors.size }#{ category.name }</option>}
html [...]