techiferous / tabulous

Easy tabbed navigation for Rails
Other
322 stars 35 forks source link

Unable to pass a param to the ACTION column in config.actions block #21

Closed matt-hwy1 closed 11 years ago

matt-hwy1 commented 11 years ago

Hi there, I just found this gem and it's a great way to get these tedious tabs up and running. Thank you for making it! I have one question specific to my app. I didn't find a way to do this myself or by searching around. I have a :new action that generates a slightly different view, based on a param it gets. I have a set of construction calculators that are launched via the :new action in my controller with a param called :calc_type to generate a different calculator. Each of these calculators are subtabs under my main "Calculators" tab. I would like to pass that param to the :new action specified in the ACTION column so that I can selectively activate/deactivate the subtabs depending on which one is clicked, even though they share the same action. Here is a snippet of the tabulous.rb code I have:

config.actions do [

----------------------------------------------------------------------------------

  #    CONTROLLER                |    ACTION          |    TAB                       #
  #----------------------------------------------------------------------------------#
  [    :calculators              ,    :all_actions    ,    :calculators_tab          ],
  [    :calculators                     ,    :new    ,    :s32_calculator_subtab    ],
  [    :calculators                     ,    :new    ,    :b43_calculator_subtab    ],
  [    :calculators                     ,    :new    ,    :r3l_calculator_subtab    ],
  #----------------------------------------------------------------------------------#
  #    CONTROLLER                |    ACTION          |    TAB                       #
  #----------------------------------------------------------------------------------#
]

Here's what I want to do:

techiferous commented 11 years ago

In order to keep things simple, I decided to have tabulous choose which tab is selected based on the current controller action. This means that a single controller action cannot have multiple active tabs associated with it.

This design constraint seems to work pretty well. I'd recommend re-organizing your actions to meet tabulous' expectations, or not using tabulous.

I think if you set up your controllers in a more RESTful, resource-oriented way, they would probably easily work with tabulous.