-
Notifications
You must be signed in to change notification settings - Fork 5
/
README
41 lines (29 loc) · 1.09 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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