Created
July 16, 2009 21:26
-
-
Save xtoddx/148702 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# examples of using before_render | |
# http://github.com/xtoddx/before_render | |
class HiController < ApplicationController | |
before_render :hook_it_up | |
before_render :double_hooked, :if => lambda{|x| false} | |
before_render :cool_action, :only => [:index] | |
before_render :lousy_action, :except => [:index] | |
# just the page | |
# def index; end | |
def index2 | |
op = render_to_string(:action => 'index') | |
render :text => op | |
end | |
def index3 | |
render :update do |page| | |
page.assign :cool, @cool_action | |
page.assign :lousy, @lousy_action | |
page.assign :hooked, @hooked | |
page.assign :double_hooked, @double_hooked | |
end | |
end | |
private | |
def hook_it_up | |
@hooked = true | |
end | |
def double_hooked | |
@doulbe_hooked = true | |
end | |
def cool_action | |
@cool_action = true | |
end | |
def lousy_action | |
@lousy_action = true | |
end | |
end | |
__END__ | |
<%# VIEW FILE %> | |
Cool action - <%= h(@cool_action.inspect) %><br/> | |
Lousy action - <%= h(@lousy_action.inspect) %><br/> | |
Hooked: <%= h(@hooked.inspect) %><br/> | |
Double? <%= h(@double_hooked.inspect) %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment