layout false if request.xhr?

Posted by Justin Reagor Mon, 13 Jul 2009 14:30:00 GMT

Rather simple actually… since ActionController::Base.layout takes a proc, and calls it upon a request.

class ApplicationController < ActionController::Base
  def self.without_layout_on_xhr
    layout proc { |controller| controller.in_popup? ? nil : "application" }
  end

  def in_popup?
    request.xhr?
  end
end

class BusyWorkController < ApplicationController
  without_layout_on_xhr

  before_filter :login_required

  def new
    @work = Busy.new
  end
end

I’ve abstracted out the conditions for rendering without a template based on the controller instance method #in_popup?. Feel free to change it to whatever you want.

Joyent Opens Connector and Slingshot 1

Posted by Justin Reagor Sat, 14 Jul 2007 03:40:00 GMT

I thought it was pretty cool to hear that Joyent open sourced what they claim to be “[Connector] represents one of the most comprehensive (and complex) use of the Rails framework to date!”

With over 30 Models, a route file to die for and various other interesting tid-bits of info… its pretty amazing to review this enormous Rails project! Big ups to Joyent for providing the Rails community with even more insightful information and support.

To pull trunk…

svn co http://svn.joyent.com/opensource/connector/source/trunk/