html - How to get options_for_select to honor   tag -


i'm trying indent options in select list of categories based upon hierarchical level, e.g. category,  subcategory,   subsubcategory.

i've tried: <% options = options_for_select @categories.map{|c| [("&nbsp;" * c.level) + c.name, c.id]} %>, renders &nsbp;subcategory , &nbsp;&nbsp;subsubcategory.

i've tried: <% options = options_for_select @categories.map{|c| [(" " * c.level) + c.name, c.id]} %>, ignores spaces , renders subcategory , subsubcategory.

as test, tried <%= ("&nbsp;" * 3) + "hello" %>, , renders how i'd expect to:    hello.

does know how results i'm looking for?

try using (("&nbsp;" * c.level) + c.name).html_safe. problem in options_for_select helper method using html_escape, escapes &nbsp; entities. adding html_safe allow html_escape method called options_for_select helper avoid escaping spaces.


Comments