Closed jh125486 closed 11 years ago
Sorry for the poor formatting of the code. I'm only authorized IE8 at work, and github barely works with this old browser.
Ah, I see what you're doing. This is the ruby-fu that you need: use the send method. It takes a symbol or a string that's the name of the method you wish to call.
send("#{car.name}_subtab") do
text { car.name}
link_path { cars_path(car }
visible_when { true }
enabled_when { true }
active_when { in_action('show').of_controller('cars') }
end
Awesome. Thanks for the help!
You're welcome!
Howdy, In the old syntax I was able to insert dynamic tabs/subtabs into the tabs array. For example if I wanted a tab named "Cars", and subtabs with links to each car under "Cars":
Tabuluous.setup do |config| config.tabs do [ [:cars_tab, 'Cars', cars_path, true, true], *Car.order(:name).map { |car| [ "#{car.name}_subtab".to_sym, car.name, car_path(car)], true, true]}, ] end end
Ugly, but this would produce: ,, tabs: | Cars | ,____, ,____, ,__, subtabs: | Mustang |__| Corvette |_| Prius |
Unfortunately since tabs/subtabs are created through method_missing in the new DSL, my ruby-fu isn't strong enough to figure this out. I've tried 'define_method', but my meta-programming is too weak at this point: Cars.order(:name).each do |car| define_method "#{car.name}_subtab".underscore.to_sym do text { car.name} link_path { cars_path(car } visible_when { true } enabled_when { true } active_when { in_action('show').of_controller('cars') } end end