October 24th, 2007, 05:01 PM
Rails view search path
I'd like to somehow change the view serach path in Rails such that when a view like say _show.rhtml is requested it first looks in path x, then y and finally z.
This mechanism would allow me to more properly subclass controllers in that I can also inherit or override the views associated with the super controller.
October 29th, 2007, 02:49 PM
Look into editing the config/routes.rb file.
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
"I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
October 29th, 2007, 03:06 PM
It seems you don't understand the problem. The routes.rb file is of no use to accomplish this.
Originally Posted by Scorpions4ever
Consider controller B which inherits from controller A. Both controllers implement a method “show”. A::show renders the template show.rhtml which in turn renders embedded templates show_part1.rhtml and show_part2.rhtml.
Ideally, I should now be able to implement my own versions of any or none of these view templates in controller B. The idea is that any view implemented for B will override the view implemented for A.
In a nutshell, what I really want is to change the Rails view lookup path. Controller B would simply append Controller A’s view path to the Rails view lookup path.
November 1st, 2007, 05:42 PM