Now I'm starting with the rails, and I'm just asking what I think. I need to display two partial elements in one ajax call:
I have the following controller:
def show
@host = Host.find(params[:id])
respond_to do |format|
format.html
format.js
format.json { render :json => @host }
end
end
And the corresponding template (show.js.erb):
$('#tabs-1').html("<%= escape_javascript(render @host) %>");
And a partial file called _host.html.erb
It all works great. The template "_host.html.erb" is displayed on div-1 tabs, but now I need to add another partial template to a different identifier (# tabs-2), but use the same @host How can I do this? by default, the render @host method will use the template file "_host.html.erb". How can I name another, for example _host2.html.erb, and have the same @host instance?
Thanks Joao
source
share