Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
How to determine the current controller?
Sven Gehring
6/24/2008 10:40:00 AM
Hi guys,
I want to build a generic navigation menu with partials in the style of
if current_controller == 'abcd'
render pratial 'abscd'
How can I determine the current controller from within the layout .rhtml
file without taking care of what action is executed?
If I use current_page?(:controller => 'abcd') it works as long as the
current_page is http://localhost:3000/abcd
--
Posted via
http://www.ruby-...
.
1 Answer
nas
6/24/2008 12:04:00 PM
0
you have an instance variable available in your views called
@controller
hence you can use something like
if @controller.controller_name == 'abcd'
do something
else
do somthing else
end
On Jun 24, 11:39 am, Sven Gehring <sven.gehr...@mac.com> wrote:
> Hi guys,
>
> I want to build a generic navigation menu with partials in the style of
>
> if current_controller == 'abcd'
> render pratial 'abscd'
>
> How can I determine the current controller from within the layout .rhtml
> file without taking care of what action is executed?
>
> If I use current_page?(:controller => 'abcd') it works as long as the
> current_page ishttp://localhost:3000/abcd
> --
> Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
How to determine the current controller?
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password