自定义awesome_nested_set默认下拉选择框

时间:2013-12-17 11:33:36

标签: ruby-on-rails ruby-on-rails-4 nested-sets html-select

我正在使用awesome_nested_set来显示类别和子类别。我用过这个

<%= f.select :parent_id, nested_set_options(Category, @category) {|i| "#{'-' * i.level} #{i.name}" }, {:include_blank => 'Base Category'},{:class => "form-control"} %>

但在这种情况下,它会添加-以显示子类别的嵌套特性。我只想使用空格而不是-连字符。请帮忙。

1 个答案:

答案 0 :(得分:1)

<%= f.select :parent_id, nested_set_options(Category, @category) {|i| "#{'&nbsp;' * i.level} #{i.name}".html_safe }, {:include_blank => 'Base Category'},{:class => "form-control"} %>

我将& nbsp;字符替换为-并将字符串设置为.html_safe