How would I render my .js.erb file here?
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 ren开发者_开发技巧ders 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_to
method, 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 :format
option. So you could do something like
redirect_to :action => 'show', :format => 'js'
精彩评论