Skip to content

trouble generating active subtab for "show" action #44

@ljulien

Description

@ljulien

I'm trying to generate subtabs dynamically. In this case, I have a limited number of Floors, and I would like to create a subtab pointing to the "show" action of the "maps" controller for each one of them.

I can successfully generate the subtabs like this:

    Floor.all.each do |floor|
      send("floor_map_#{floor.id}_subtab") do
        text          { "Floor #{floor.id}" }
        link_path     { map_path(floor) }
        visible_when  { true }
        enabled_when  { true }
        active_when   { (floor.id == @floor) and in_action('show').of_controller('maps') }
      end
    end 

but I can't successfully make the proper one active. I have set the @floor variable in the controller, but it doesn't seem to be set (or it is otherwise not available) when active_when is called.

My ( floor.id == @floor ) test works correctly in the enabled_when and visible_when blocks, but not in active_when. Since the parent tab is set to "active_when { a_subtab_is_active }" I really do need to make the proper tab active.

Any ideas?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions