Low commit activity in last 3 years
There's a lot of open issues
No release in over a year
A development tool for rendering and debugging views that wouldn't otherwise be rendered in your application
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 6.1
 Project Readme

ActionViewPreview

Sometimes being able to preview a view might come in handy, like when a view is going to be used only inside a PDF, for example.

This gem allows a setup similar ActionMailer::Preview, and provides a development tool for rendering and debugging views that wouldn't otherwise be rendered in your application.

Installation

Add this line to your application's Gemfile:

gem 'action_view_preview'

And then execute:

$ bundle

Or install it yourself as:

$ gem install action_view_preview

Usage

Command Line Install

Run rails generate action_view_preview:install and the generator should create a hello_preview.rb and mount the route in your routes.rb file, similar to the steps shown below in the manual install.

Manual Install

  1. Mount the engine in your routes.rb:
Rails.application.routes.draw do
  # Add the line below
  mount ActionViewPreview::Engine => "/action_view_preview"
end
  1. Create files *_preview.rb on test/views/previews/, e.g. hello_preview.rb:
class HelloViewPreview < ActionViewPreview::Base
  def hello
    '<b>Hello world</b>'
  end
end
  1. Access the route /action_view_preview to see the available previews

Configuration

Use config.action_view_preview on config/application.rb to add custom configuration. For example, if you want to place the preview files in lib/view_previews:

config.action_view_preview.preview_path = "#{Rails.root}/lib/view_previews"

Possible config values:

Config Default Description
preview_path test/views/previews Path to the preview files

License

The gem is available as open source under the terms of the MIT License.