# Routing\_navigator plugin problems

**URL:** <https://www.ruby-forum.com/t/routing-navigator-plugin-problems/133025>\
**Category:** Rails\
**Created:** [March 26, 2008, 9:01pm UTC](https://www.ruby-forum.com/t/routing-navigator-plugin-problems/133025 "2008-03-26T21:01:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [March 26, 2008, 9:01pm UTC](https://www.ruby-forum.com/t/routing-navigator-plugin-problems/133025/1 "2008-03-26T21:01:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [April 6, 2008, 6:39pm UTC](https://www.ruby-forum.com/t/routing-navigator-plugin-problems/133025/2 "2008-04-06T18:39:20Z")

</div>

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.

On Mar 26, 3:01 pm, James B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [April 6, 2008, 7:25pm UTC](https://www.ruby-forum.com/t/routing-navigator-plugin-problems/133025/3 "2008-04-06T19:25:14Z")

</div>

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.
