Created
January 19, 2012 14:34
-
-
Save jarod022/1640319 to your computer and use it in GitHub Desktop.
Méthode choose_layout (annule le layout si Ajax)
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
# 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