method

default_render

default_render(#:nodoc:)
private

No documentation available.

# File actionpack/lib/action_controller/base.rb, line 1325
      def default_render #:nodoc:
        render
      end

3Notes

RE: 1 render definition for many actions (cleaner)

arronwashington · Nov 4, 20082 thanks

Hi James,

Unfortunately that doesn't work if you use the @zombies variable in the rendered template, which is why default_render was added as a patch AFAIK. :)

before_filter is called too soon, after_filter is called after an attempt at rendering is made, so default_render is the only option for this as far as I know.

1 render definition for many actions.

arronwashington · Nov 4, 2008

Overriding default_render in especially useful when you have many actions that all render the same thing.

before_filter :render_filter, :only => [:zombies, :cool_zombies]

def zombies
@zombies = Zombie.find(:all)
end

def cool_zombies
@zombies = Zombie.find(:all, :conditions => { :eats_humans => false, :is_hippie => true })
end

protected

def render_filter
instance_eval do
  def default_render
    render :template => 'zombies/all'
  end
end
end

RERE: 1 render definition for many actions (cleaner)

james · Nov 4, 2008

@arronwashington. Ah, so that's the motivation for using default_render, thanks for clearing that up, thanks :)