https://github.com/tknarr/before_render
Add a before_render filter to rails. Compatible with Rails 5 only.
https://github.com/tknarr/before_render
gem rails5 ruby ruby-gem ruby-on-rails
Last synced: 9 months ago
JSON representation
Add a before_render filter to rails. Compatible with Rails 5 only.
- Host: GitHub
- URL: https://github.com/tknarr/before_render
- Owner: tknarr
- License: mit
- Fork: true (shell/rails3_before_render)
- Created: 2016-03-04T02:46:37.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-01-29T08:19:03.000Z (over 8 years ago)
- Last Synced: 2024-04-27T16:45:50.417Z (about 2 years ago)
- Topics: gem, rails5, ruby, ruby-gem, ruby-on-rails
- Language: Ruby
- Homepage:
- Size: 32.2 KB
- Stars: 0
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE
Awesome Lists containing this 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.