Render .rhtmlx if present, otherwise render .rhtml

We have a product where our customer is “allowed” to make minor changes
to the .rhtml views.

Obviously, this can be an issue when updating the software, as changes
need to be merged in. Also, sometimes the customer wants to back out
there change but no longer has the original file.

SOOO…

I’d like to tell them

  • if you want to change a .rhtml file
  • just copy it to .rhtmlx and change away

Then rails will pick up the .rhtmlx if present, otherwise will render
the normal .rhtml

Any idea of a good/easy way to do this ?

– THanks

On 1/25/07, [email protected] [email protected] wrote:

I’d like to tell them

  • if you want to change a .rhtml file
  • just copy it to .rhtmlx and change away

Then rails will pick up the .rhtmlx if present, otherwise will render
the normal .rhtml

Any idea of a good/easy way to do this ?

No clue if this works, but it’s an idea from looking at ActionView for
a few minutes…

path = “show”
if template_exists?(path, :rhtmlx)
render :action => “#{path}.rhtmlx”
else
render :action => path
end

Look at how ActionView picks which template to render for further
reference:
http://dev.rubyonrails.org/browser/trunk/actionpack/lib/action_view/base.rb


Rick O.
http://weblog.techno-weenie.net
http://mephistoblog.com

I’m not really sure on this, but I’ve been reading up on RESTful stuff
lately and this seems like it could be a great use for the respond_to?
example here: