So what's happening is that for HTML requests the HTML template will
be rendered (inside application.html.erb) and for Javascript requests
I want the HTML template to be rendered as a string into the
Javascript snippet so that jQuery can throw out a dialog. The catch is
that dialogs have a separate layout file, dialog.html.erb.
Is there a way to render a template with a layout into my Javascript
snippet where I've typed "render XXX"? I've looked at render_to_string
but that breaks MVC by taking view material into the controller.
Ideally, I'd like something like render(:action =>
'index.html.erb', :layout => 'dialog') (note index.html.erb to
distinguish it from index.js.erb) and have this rendered inline.
Is there a way to render a template with a layout into my Javascript
snippet where I've typed "render XXX"? I've looked at render_to_string
but that breaks MVC by taking view material into the controller.
Ideally, I'd like something like render(:action =>
'index.html.erb', :layout => 'dialog') (note index.html.erb to
distinguish it from index.js.erb) and have this rendered inline.
I think either render :template, or render :action => ..., :format =>
'html' would do this
After reading the docs for ActionView::Base.render (http://apidock.com/
rails/ActionView/Base/render) I found that ActionView's render is
quite different to ActionController's render. Notably, there aren't
options for :template or :action. However, there is an option
for :file and you can also provide a :layout option which I've done: