I’ve built a simple content management system and I’m trying to build a dynamic navigation bar but the approach I’ve came up with is to keep sending an array of all the pages to the application template from each controller. Is there a better approach to this?
Share
As @Amit Patel mentioned in the comments to your question, the better approach is to move the code you’re referring to into the
ApplicationController.All controllers in your application extend the
ApplicationControllerclass. Any functionality you want to share amongst all controllers can be placed in this class.As an example (since you’ve provided no actual code), you might set this up as a
before_filterThe before_filter will run for all actions in all controllers, effectively making
@pagesavailable to every template in your application.