Rendering templates outside defaultl views location

Hi,

I’d like to accomplish the following situation (pseudo code):

IF file /path/to/some/tpldit exists
render that
ELSE
render file from default tpl dir
END

Should I override some built-in Rails methods for this or is there an
easier (yet clean and DRY) way of doing this?

I’ve done something similar for the assetTagHelper related functions
using a tiny plugin that overrides some built-in Rails methods, but I’d
like to avoid that if I can.

TIA,

Jeroen

Am Montag, den 13.03.2006, 15:18 +0100 schrieb Jeroen H.:

Should I override some built-in Rails methods for this or is there an
easier (yet clean and DRY) way of doing this?

I’ve done something similar for the assetTagHelper related functions
using a tiny plugin that overrides some built-in Rails methods, but I’d
like to avoid that if I can.

def my_action

action code goes here

render ‘/path/to/some/tpldit’ if File.file?(‘/path/to/some/tpldit’)
end

Unless the specific file is existent, the action method ends and the
default view gets rendered. Pretty clean, isn’t it?

If this is a general logic in your application - maybe you have two
template directories, that mostly contain both my_action.rhtml files,
but some not - you should overwrite the render or template find method.

Norman T.

http://blog.inlet-media.de