kirk bushell | Riding the wave of programmatic novelty

Theme_support plugin - not that evil

March 04, 2009 at 10:15 AM · Posted under Blog · Tagged with ,

One of the most recent tasks I've had to complete at the office was to provide some sort of templating/theming system for one of our products. After a very small search, I stumbled upon the view_paths array and started fiddling, only to find I couldn't get layouts to work. I then moved onto a plugin called theme_support and had exactly the same problem. This caused days of grief (4, to be exact) without it ever occurring to me that maybe I'd have to set the layout. Well this morning I went about trying just that and lo and behold - IT WORKS! This is an incredibly frustrating lesson, as a simple one-line piece of documentation within the plugin would state that a layout has to be specified in order for this to work. Now, I could be wrong, but I'm fairly certain rails by default looks for a layout file of the same name as the controller aka: layouts/controller.html.erb. Considering that it's not able to do this unless a layout is specified, leads me to believe that there may be a bug within the layout.rb file that prevents this search from working if no layout is specified, but the view_paths are changed. In any case, I will be adding some comments to the theme_support plugin, as I think this is fairly fundamental and has been overlooked. Now that I have got it to work, theme_support is working as intended and I can get on with my life. Thanks to everyone on the rails-oceania Google Group for helping me out, especially Terry Heath. Moral of the story - test every single part of code given in examples when working with a new plugin.

Comments

Leave a Comment