No commit activity in last 3 years
No release in over 3 years
provides a before_render method for action_controllers
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

~> 4.0
 Project Readme

Before Render

Introduction

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).

Plugin heavily based on Vladimir Penkin's rails3_before_render which in turn is based on before_filter for Rails 2 by Todd Willey.

Provided methods:

  • before_render
  • prepend_before_render
  • skip_before_render

Installation

gem 'rails5_before_render'

Warning: Rails 5 only.

Usage

before_render / prepend_before_render / skip_before_render works as other filters. Options like :except and :only can be passed to filter.

class PostsController < ApplicationController
    before_render :ping, :except => [:destroy]

    def index; end     

    def new; end

    def show; end

    def destroy; end                                                                          
          
    private

    def ping
        Rails.logger.info "Ping-Pong actions"
    end
end       

Method ping will be executed after your actions and before template is rendered.

Author

Copyright (c) 2013 Nilesh Chaudhari, released under the MIT license. Plugin heavily based on Vladimir Penkin's rails3_before_render which in turn is based on before_filter for Rails 2 by Todd Willey. Updated by Todd Knarr to supersede the outdated version on RubyGems and to depend explicitly on Rails 5.x so it won't break with later versions, gem renamed to avoid collision with the outdated version.