Add a hook like after_filter, but runs before your action is rendered
Ruby
Switch branches/tags
Nothing to show
Permalink
Failed to load latest commit information.
lib Removed use of Object#returning. Sep 6, 2010
tasks Add test cases. Jul 17, 2009
test Add test cases. Jul 17, 2009
MIT-LICENSE Initial commit Feb 13, 2009
README Point googlers to the rails 3 version. Nov 19, 2013
Rakefile Initial commit Feb 13, 2009
init.rb Initial commit Feb 13, 2009

README

Rails 3
=======

Using rails3? See https://github.com/shell/rails3_before_render

BeforeRender
============

Add a hook like before_filter to your controllers that gets executed between
when your action is completed and the template is rendered.  It can really
DRY up loading some data that is used for views (headers / layouts / etc).

Provided methods:
  before_render / before_render_filter / append_before_render_filter (aliases)
  prepend_before_render_filter

TODO
====

It doesn't have the skip_before_render_filter logic.

ActionController::Filters::FilterChain encodes logic about the types of filters
that exist all over the place where it could be more generic, maybe try to
merge some of this back into rails core.

Example
=======

class MyController < ApplicationController
  before_render :load_header_image_based_on_hostname

  private
  def load_header_image_based_on_hostname
    @header_image = HeaderImage.src_for_request(request)
  end
end

# in the layout or view
<img src="<%= @header_image %>" alt="header image" />

Copyright (c) 2009 [name of plugin creator], released under the MIT license