Needing to extend Rails view path
By default, I believe ActionView only looks in the ‘views’ folder for any templates and/or partials, which makes sense. But what if I have a bunch of static partials (not related to a specific controller) that I didn’t want cluttering my ‘views’ directory? How could I extend the view path to realize an additional directory? Lets say, ‘lib/content’ or ‘public/content’? Or what about another computer entirely?
Here’s my situation: I have to work with some “published” content (which is no more than a strict folder structure with embedded HTML files), and allow a user to navigate through that content. I can’t change what needs to be done, but I do have a little control over the filenames that get published. I thought I could publish them in the _partial.rhtml format, and in my application, deal with the directory hunting to find what I need, rendering each partial accordingly. For very valid reasons, I’m unable to modify the system that publishes the content any further than the filenames, so I have to work within the given constraints.
The published content has potential to get rather large, so I’d like it separate from my ‘views’ directory. Plus, it has nothing to do with my application; it’s just static content I need to read in. Ideally, I’d like to be able to reference a directory on another server (which seems like a lot to ask); but I could tolerate having a ‘public/content’ folder. Any thoughts on how to add another directory to the view path in order to make something like render :partial => "public/content/partial" become an option?

Chris Wednesday, 07 Feb, 2007 Posted at 07:24AM
Check out the theme support plugin, and then you could modify the directories it uses. (I messed around with this, essentially just copying the code from the action view patch ).
Ryan Wednesday, 07 Feb, 2007 Posted at 01:40PM
Ok, thanks… I’ll look into that. I wish there was something really simple, like…
ActionView::Base.new do |av| av.base_path.add = "#{RAILS_ROOT}/public/junk" endBut I’m just being lazy on this one.
Chris Wednesday, 07 Feb, 2007 Posted at 05:23PM
Yeah, I wished it were that easy as well… unfortunately, it’s a TEMPLATE_ROOT constant in ActionView :-/
dphus Wednesday, 03 Oct, 2007 Posted at 05:27PM
If all you are wanting to be able to do is access different folders for the sake of partials you can use standard directory navigation.
will get you to a partial ‘_stuff.rhtml’ in your standard public folder. i’ve never tried traversing outside of my rails application directory structure, but i think it’s possible. further with clever use of symbolic links, you could access directories across the network (assuming you’re on *nix).
does that help?
pete Thursday, 01 Nov, 2007 Posted at 02:49PM
Here is an idea:
http://railsforum.com/viewtopic.php?pid=44098
Tom Thursday, 06 May, 2010 Posted at 04:12AM
Okay, this thread is way old but nevertheless here my suggestion:
I made a soft link the way:
../app/views: ln -s ../../public/my_public_folder my_public_folder
afterwards something like:
<%= render :partial => “my_public_folder/partial” %>
worked for me
cheers Tom