routing_navigator plugin problems

Has anyone got this working under Rails 2.0.2? I get

undefined method `template_root=' for RoutingNavigatorController:Class

When I try and use it. I discovered a previous post on the subject but
the advice given there (substitute view_paths for template_root) does
not work for me.

I had the same problem and fixed it.

The problem is the way the system trys to change the path of the
template root so it can include it's own templates and partials.

My fix is quick and dirty because I need it working now and elegance
is not on my highest priority list... but here is my fix.

class RoutingNavigatorController < ActionController::Base
  routing_navigator :off if respond_to? :routing_navigator
  # self.view_paths << File.join(RAILS_ROOT, 'vendor/plugins/
routing_navigator/views')

#for access by the model
  def self.view_path
     File.join(RAILS_ROOT, 'vendor/plugins/routing_navigator/views')
  end

  def index
#manually added
    self.view_paths << File.join(RAILS_ROOT, 'vendor/plugins/
routing_navigator/views')
    @filter = YAML.load(params[:filter].to_s).symbolize_keys rescue
nil
  end

  def recognize_url
    render :text
=> ::ActionController::Routing::Routes.recognize_path(params[:path]).inspect, :layout
=> false
  end

  def generate_route
    render :text
=> ::ActionController::Routing::Routes.generate(YAML.load(params[:options]).symbolize_keys).inspect, :layout
=> false
  end
end

#in routing_navigator.rb ~line 32
ActionController::Base.class_eval do
  class_inheritable_reader :routing_navigator_options
  after_filter :append_routing_navigator if RAILS_ENV == 'development'

  # Set what actions the routing navigator after filter is
  def self.routing_navigator(options = {})
    options = { options => true } if [:off, :on].include?(options)
    write_inheritable_hash :routing_navigator_options, options
  end

  protected
    def append_routing_navigator
      options = routing_navigator_options || {:off => true}
      # yuck!
      return if request.xhr? || options[:off] || (!
params[:format].blank? && params[:format] != 'html') || (response.body
=~ /<\/body/).nil? ||
        (options[:only] && !
[options[:only]].flatten.collect(&:to_s).include?(action_name)) ||
        (options[:except] &&
[options[:except]].flatten.collect(&:to_s).include?(action_name))
      # yuck!
      # old_template_root = @template.view_paths
      begin
        @template.view_paths << RoutingNavigatorController.view_path
        response.body.gsub!(/<\/body/, @template.render(:partial =>
'routing_navigator/navigator') + '</body')
      ensure
        @template.view_paths = old_template_root
      end
    end
end

Try that and it should work.

codeninja wrote:

I had the same problem and fixed it.

I fixed the problem as well, although my solution was even more blunt
force than yours. I simply removed the problematic
template_root/views_path calls from the plugin and copied the
views/routing_navigator directory to app/views.

I have submitted a patch for this plugin to the maintainer, at his
request, but I have not received any acknowledgement and it has not been
committed.