awesome_nested_set How to not select a parent?

I just got awesome_nested_set put in place and all is working well. I converted over from acts_as_tree using Category.rebuild! listed on the github link.

Problem is, I do not have the option to create a node on the top level with no parent (e.g. - There is no blank <option> in the form select). This is the select_tag I am using:

<%= select_tag 'parent_id', options_for_select(nested_set_options(Page) {|i| "#{'..' * i.level} #{}" } ) %>

I'm a RoR newb so I'm unsure of how to make it so I can create a page on the top level. Can someone point me in the right direction?


In order to create a record at the root level, simply leave parent_id nil. You will need to add an option for that:

<%= select_tag 'parent_id', options_for_select(
      nested_set_options(Page) {|i| "#{'..' * i.level} #{}" }.unshift(["No Parent", nil])
    ) %>

It's probably time to move this into a helper.

Need Your Help

Python unittest mock … mock a module statement

python unit-testing python-2.7 mocking xbmc

I'm having difficuly getting my head around python's mock test methodology.

Finding the number of edges and performing a topo sort in my graph implementation

c++ graph graph-algorithm topological-sort

I have been working on a graph implementation for the last few days. All of this is really new to me, and I am stuck on two parts of my implementation. I am implementing a digraph of courses from an

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.