Tiens, au fait, qu'en dit la doc ?...

Conditional layouts

If you have a 
layout<http://api.rubyonrails.org/classes/ActionController/Layout/ClassMethods.html#M000621>that
by default is applied to all the actions of a controller, you still
have the option of rendering a given action or set of actions without a
layout<http://api.rubyonrails.org/classes/ActionController/Layout/ClassMethods.html#M000621>,
or restricting a
layout<http://api.rubyonrails.org/classes/ActionController/Layout/ClassMethods.html#M000621>to
only a single action or a set of actions. The
:only and :except options can be passed to the
layout<http://api.rubyonrails.org/classes/ActionController/Layout/ClassMethods.html#M000621>call.
For example:

  class WeblogController < ActionController::Base
    layout "weblog_standard", :except => :rss

    # ...

  end

 This will assign "weblog_standard" as the WeblogController's
layout<http://api.rubyonrails.org/classes/ActionController/Layout/ClassMethods.html#M000621>except
for the
rss action, which will not wrap a
layout<http://api.rubyonrails.org/classes/ActionController/Layout/ClassMethods.html#M000621>around
the rendered view.

Both the :only and :except condition can accept an arbitrary number of
method references, so #:except => [ :rss, :text_only ] is valid, as is :except
=> :rss.
Using a different
layout<http://api.rubyonrails.org/classes/ActionController/Layout/ClassMethods.html#M000621>in
the action render call

If most of your actions use the same
layout<http://api.rubyonrails.org/classes/ActionController/Layout/ClassMethods.html#M000621>,
it makes perfect sense to define a controller-wide
layout<http://api.rubyonrails.org/classes/ActionController/Layout/ClassMethods.html#M000621>as
described above. Sometimes you'll have exceptions where one action
wants
to use a different
layout<http://api.rubyonrails.org/classes/ActionController/Layout/ClassMethods.html#M000621>than
the rest of the controller. You can do this by passing a
:layout<http://api.rubyonrails.org/classes/ActionController/Layout/ClassMethods.html#M000621>option
to the
render call. For example:

  class WeblogController < ActionController::Base
    layout "weblog_standard"

    def help
      render :action => "help", :layout => "help"
    end
  end

 This will render the help action with the "help"
layout<http://api.rubyonrails.org/classes/ActionController/Layout/ClassMethods.html#M000621>instead
of the controller-wide "weblog_standard"
layout<http://api.rubyonrails.org/classes/ActionController/Layout/ClassMethods.html#M000621>.

-- 
Michel Belleville

--~--~---------~--~----~------------~-------~--~----~
Vous avez reçu ce message, car vous êtes abonné au groupe "Railsfrance" de 
Google Groups.
Pour transmettre des messages à ce groupe, envoyez un e-mail à l'adresse 
[email protected]
Pour résilier votre abonnement envoyez un e-mail à l'adresse [EMAIL PROTECTED]
-~----------~----~----~----~------~----~------~--~---

Répondre à