Evan wroteat 3:11pm on September 10th, 2008
I approached this slightly differently using the url_for as the core of my tab_selected? method and compared it to the current url, perhaps not the cleanest but just another option.
This lesson shows you how to render a facebook tab control.
FBML tab control is handled by two methods, fb_tabs and fb_tab_item. If you check out the wiki you will see that fb_tabs tag contains some number of fb_tab_item tags. Here is how the tab control is created for this tutorial.
1 2 3 4 |
#File: app/helpers/application_helper.rb Method: tab_selected? def tab_selected?(section) (section.lessons.first.url_options[:controller] == params[:controller]) end |
1 2 3 4 5 |
# File: app/views/layouts/_section_tabs.rhtml <% fb_tabs do %> <%= section_tab_items() %> <% end %> |
1 2 3 4 5 6 |
#File: app/helpers/application_helper.rb Method: section_tab_items def section_tab_items LessonOutline.outline.sections.collect do |section| fb_tab_item(section.name, url_for(section.lessons.first.url_options), :selected => tab_selected?(section) ) end.join("\n") end |







