techiferous / tabulous

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

Problems with config.when_action_has_no_tab = :do_not_render #17

Closed santuxus closed 12 years ago

santuxus commented 12 years ago

Hi,

I'm having problems with actions that shouldn't have tabs. In my tabulous.rb I have lines like:

config.tabs
 ...
 [    :place_tab     ,    'Place info'    ,    place_path(params[:id])              ,    true        ,    true        ],
end

config.actions
  ...
  [    :places       ,    :show           ,    :place_tab    ],
end

For places#index I don't want to show tabs, but I keep geting error:

No route matches {:action=>"show", :controller=>"places", :id=>nil}

It looks like, tabulous tries to calculate everything for tabs, eventhough it's not going to show them... if I do

config.tabs
 ...
 [    :place_tab     ,    'Place info'    ,    place_path(params[:id] || 1)              ,    true        ,    true        ],
end

it works (no tabs are shown, as it should be). Is there a cleaner solution for this? Is it possible to prevent tabs code execution if no tabs are going to be shown? Or am I taking wrong approach and I should put paths' calculation to some helper and verify params there?

Thanks for any suggestions, Regards

Santuxus

techiferous commented 12 years ago

Thanks for bringing this up. I would say work around this with conditional logic, as you are doing. For example,

[  :place_tab     ,    'Place info'    ,    ( params[:id] ? place_path(params[:id]) : '#'  )    ,    true    ,   true   ],
santuxus commented 12 years ago

Thanks for your answer - I will use something like that ;)