Tabbed Navigation

Went back and forth a bit trying to find out the easiest way to do this. Found a plugin but it didn’t seem very stable/well written.

This is what I have going right now:

  • if @content_for_recipe_editor_tabs

    = yield :recipe_editor_tabs

  • else

    = tabbed_navigator(RecipesController.send “edit_tabs”)

If any templates/sub-templates/partials used in this render have something like this:

  • content_for( ‘recipe_editor_tabs’ ) do = tabbed_navigator(RecipesController.send “new_tabs”)

That content will be used in place of the content specified in the else block.

Here’s what new_tabs and edit_tabs looks like.

def self.new_tabs

[tab("Description", :new_ingredient_path, :needs => [

:recipe])] end

This will likely abstract a little more as we add more views that need tabbed_navigators, but I’ll hold off on that to see where the repetition crops up.

‘tabbed_navigator’ helper takes the array of tabs and renders them as an ul with links. Highlighting rules are currently done with a current_page? call.

tab(name, url_for_method, options) Returns a Hash with greater verbosity and possible defaults.

What was the problem with the seesaw plugin? I was able to make it work pretty much right away. (I know that’s not much help …)