views:

18

answers:

2

I have use tabs_on_rails plugin to do tabs view. and its documentation told me that we can custom a builder to override methods like

  • open_tabs: the method called before the tab set
  • close_tabs: the method called after the tab set
  • tab_for: the method called to create a single tab item

the problem is I don't know where to put the override code? Does anyone can help me?

A: 

If you put the custom builder class in a file within your Rails application's /lib directory then it will be automatically loaded by Rails.

John Topley
Thanks a lot! I have put the class in a rb file within /lib, but it still can't work. It output "uninitialized constant ActionView::CompiledTemplates::MenuTabBuilder"? why?
VvDPzZ
+1  A: 

@Topley is right but not enough. You should put the particular class input /lib and name it as menu_tab_builder.rb Then you will find that it still doesn't work because of Rails3. In addition, you need to add open_tabs and close_tabs function.

# the following is necessary to make this rails3 compatible
def open_tabs(options = {})
   @context.tag("ul", options, open = true)
end
  # the following is necessary to make this rails3 compatible
  def close_tabs(options = {})
    "".html_safe
  end

Good luck!

tzzzoz