Skip to content

Instantly share code, notes, and snippets.

@jarod022
Created January 19, 2012 14:34
Show Gist options
  • Save jarod022/1640319 to your computer and use it in GitHub Desktop.
Save jarod022/1640319 to your computer and use it in GitHub Desktop.
Méthode choose_layout (annule le layout si Ajax)
# dans application_controller
private
# Charge le layout qui porte le même nom que le Namespace
# retourne aucun layout si la requête est en AJAX
def choose_layout
namespace = self.class.name.split("::").first.downcase
(request.xhr?) ? nil : namespace
end
# Exemple d'utilisation dans un controller
class Admin::AdminController < ApplicationController
layout :choose_layout
# A faire : faire passer un paramètre pour choisir le layout à charger.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment