-
-
Save hughevans/145974 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Three things to add: | |
# * before_filter call | |
# * action_has_layout? method (if you have one, combine them) | |
# * adjust_for_inline | |
# | |
class ApplicationController < ActionController::Base | |
# ... | |
before_filter :adjust_for_inline | |
# ... | |
private | |
# We don't want no stinking layout if it's an AJAX request. | |
def action_has_layout? | |
request.format != :inline && super | |
end | |
# Careful not to bugger up JS/other XHR requests | |
def adjust_for_inline | |
request.format = :inline if request.format == :html && request.xhr? | |
end | |
# ... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add this line to your existing file. | |
# Jury's out on the best name for the pseudo-mimetype though. | |
Mime::Type.register_alias "text/html", :inline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A long time ago, in an action far far away | |
def index | |
# ... | |
respond_to do |wants| | |
wants.inline { | |
render :template => 'controller/_partial' | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment