views:

290

answers:

2

I'm now implementing navigation tabs for my Rails application. I would like to generate different CSS and html for current tab (add id="current" and do not link the title) - basic stuff.

I found the function: current_page? but unfortunately it doesn't work in a way i would expect:

When I call: current_page?(:controller => "bank_account") it returns true for /bank_account but not for /bank_account/soem_action

Is there a way to force current_page? to return true in this case? So when I don't specify the action it should return true for all the actions of the given controller.

A: 

You could use

controller.controller_name

to retrieve the controllers name in a view.

Beffa
it doesn't work in my case as I can have the urls like:- /admin/users (where users is controller and /admin is just a subdir)- /usersFor both cases the controller name is users - current_page? works well but fails when I add actions. It looks like i will have to reimplement the current_page? to suit my needs.
j t
But controller.controller_name will return users in this case. Maybe I don't get it.
Beffa
What about params[:controller], IIRC that returns the controller name along with the "admin" namespace: params[:controller] == "admin/users"
ryanb