Global Controls

I’m coming from an ASP.NET background. Perhaps someone with some .net
experience can shed some light on how to best implement this type of
thing
in rails. In .net I usually have global user controls that I embed on
almost every page using a Master page. For example, I’ll have a
PrimaryNav.ascx with has a codebehind file to pull the navigation schema
from the database. I include this user control in the a master page so
by
default it appears on every page. I’m trying to figure out how in rails
to
do something like this. I’ve thought about including a partial in a
layout
but I don’t know where the business logic to pull a dynamic navigation
schema would reside. Any help is greatly appreciated, thanks!

On 10/14/06, blinking bear [email protected] wrote:

schema would reside. Any help is greatly appreciated, thanks!

Personally, in most cases I would go down the road of a partial in the
layout. You can populate your instance varaible using a before filter
in
you application controller

class ApplicationController < ActionController::Base

before_filter :set_user_menu

private
def set_user_menu
logic in here to setup the instance variables for the menu
end
end

By using a before filter in your application contoller you can be sure
that
the data will be available for your partial.

If you have situations in a controller where you don’t want this to
occur,
use the skip_before_filter

class MyController < ApplicationController
skip_before_filter :set_user_menu, :only => [ ‘login’, ‘signup’]

end

Hope that helps…