Created — forked from jarod022/gist:1640319

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Méthode choose_layout (annule le layout si Ajax)

View gist:1640335
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# 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
Something went wrong with that request. Please try again.