app/helpers/menus_helper.rb in fullstack-cms-0.1.5 vs app/helpers/menus_helper.rb in fullstack-cms-0.1.6

- old
+ new

@@ -1,9 +1,13 @@ module MenusHelper + def find_or_create_menu(uid) + Menu.find_or_create_by_uid(uid, :name => "#{uid}".gsub("-", "_").humanize) + end + def nav_items_for(uid) - menu = Menu.find_or_create_by_uid(uid, :name => "#{uid}".humanize) + menu = find_or_create_menu(uid) html = "" menu.links.each do |link| unless block_given? html << nav_item(link.label, link_url(link)) @@ -13,12 +17,11 @@ end html.html_safe end - def menu(uid, options = nil, &block) - content_tag(name, content_or_options_with_block = nil, options = nil, escape = true, &block) + def render_menu(uid, options = nil, &block) content_tag :ul, nav_items_for(uid, &block), options, false end def link_url(link) @@ -28,10 +31,14 @@ elsif url.starts_with?("content://") klass_name, id = url.gsub("content://", "").split("#") klass = klass_name.constantize resource = klass.find(id) - page_path_for(resource) + if resource + page_path_for(resource) + else + "#" + end else url end