On 10/14/06, blinking bear
<blinkingbear-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> 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!
>
> -
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...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---