# Filters added to this controller will be run for all controllers in the application. # Likewise, all the methods added will be available for all controllers. class ApplicationController < ActionController::Base model :domain attr_writer :root_node attr_reader :root_node before_filter { |c| c.root_node = Domain.find_by_name(c.request.host) if c.root_node.nil? } def parse_path # Set the current object to the root node for the current domain obj = root_node # Set the default action to index action = 'index' # Loop through each path element for path_item in params[:path] # Find the new path element in the children of the current node new_obj = obj.children.find_by_name(path_item) # If the new path element is not found if new_obj.nil? # Then set the current path element to the action action = path_item # and exit the loop break end # Make the child the current node obj = new_obj end node_controller = obj.class_name.to_s.underscore # logger.debug( node_controller ) # Render the node and action render_component :controller => node_controller, :action => action, :id => obj.id, :obj => obj, :params => params end end