Skip to content

Instantly share code, notes, and snippets.

@gnepud
Forked from jarod022/gist:1640319
Created January 19, 2012 14:35
Show Gist options
  • Save gnepud/1640335 to your computer and use it in GitHub Desktop.
Save gnepud/1640335 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