#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    44
    Rep Power
    11

    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.
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,607
    Rep Power
    4247
    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
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    44
    Rep Power
    11
    Originally Posted by Scorpions4ever
    Look into editing the config/routes.rb file.
    It seems you don't understand the problem. The routes.rb file is of no use to accomplish this.

    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.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    44
    Rep Power
    11
    Here is a solution:

    Subclassing controllers and views

IMN logo majestic logo threadwatch logo seochat tools logo