I have a before_filter in my Rails app that sends users to login_url if they are logged out when they submit a request (in either html or js format).
I would like my format.js to produce an identical result to format.html, in the following case to render the view with the ‘notice’ layout. How can I do this?
respond_to do |format|
format.js
format.html{ render :layout => "notice" }
end
you can force the usable formats like this :
EDIT:
What you need is some part of the document being replaced by the response. This is done by responding with a javascript that does the job:
In your controller :
In your login.js view :
… or something similar