I’m using Boxy.js to call my /signup page into a modal window. I suppose it’s Ajax. I want the page to not render with layout when it’s being called this way.
I tried:
layout proc {|controller| controller.request.xhr? ? false: "application" }
and:
def render(*args)
args.first[:layout] = false if request.xhr? and args.first[:layout].nil?
super
end
in application controller, snippets I googled but they don’t work. /signup is still coming up with the layout.
Here’s part of the headers when /signup is called by Boxy:
Request URL:http://localhost:3000/signup?_=1301708866195
Request Method:GET
X-Requested-With:XMLHttpRequest
Best practice is to use Rails’ js response, like so:
But because jQuery won’t send the proper XHR headers by default, you’ll need to add something like this to your application.js:
If you’d rather just use something quick and dirty, try this: