I have a lovely web-application, under controller “Child”, and would
like to “include” it in a page under another application having
controller “Parent.” The natural way to do this, I would have
thought, would be to incorporate it in one of Parent’s views using
render_component, thus:
<%= render_component :controller => "Child", :action => "foo" %>
So far, so good. The page appears to render wonderfully in the
parent app, just as I intended. My problem is that internal links
and more important, Ajax urls on that page, generated by the view in
child/view/foo.rhtml comes from code like the following:
<%= link_to :action => "bar1" %>
…
<%= form_remote_tag :url => { :action => “bar2”} . . .
…
<%= link_to_remote :action => “bar2” %>
and the like.
The links, when running from a call to “http://localhost:3000/child/
foo”, properly generate links to the corresponding portions of Child,
generating urls like:
child/bar1
child/bar2
child/bar3
but when running under Parent, using the “render_component” generates
parent/bar1
parent/bar2
parent/bar3
which is not inconsistent with the documentation, but inconsistent
with my intent. Particularly when trying to componentize an Ajax
application, this is a disappointing result, as I was hoping to
encapsulate the internal portions of, in this case, a form editor.
One solution, of course, is to simply rewrite the sub-app with every
link_to, form_remote_tag and link_to_remote having a hard-
coded :controller parm, but is that the Rails way? Is there a
better, simpler way to accomplish what I desire?
Thanks for your time and thoughts.