I have a form that hits a controller action. The controller action redirects to another action (my create action) and I have this code:
respond_to do |format|
format.html
format.js
end
I have a create.js.erb file that I want to render after that. However, the file is not being rendered. I was thinking that it was not rendering because I needed to add :remote => true to the form, but this does not make a difference because the first controller action that my form hits is not the one that renders the .js.erb file.
How should I set this up so that I render my .js.erb file?
If I understand what you’re describing correctly, you are hitting one controller action that then redirects to another action using the
redirect_tomethod, and you want the second action to respond with a javascript template. If that’s the case, you can specify the format in your redirect request using the:formatoption. So you could do something like