Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 35 lines (22 sloc) 1.272 kb
35847c7 readme updated
Abhishek Yadav authored
1 ## Preview
2
3 Make an ActiveRecord object preview-able, and display the preview using existing/custom templates
4
5 ## Install
6
7 gem install preview
8
9 ## Usage
10
11 ### Within controller:
12
13 previewable
14 This will enable preview generation for the resource that is handled by the controller (eg: post for PostsController)
15
16 ### Within view-form:
17
18 f.preview
19 Will generate a __preview__ button, on pressing which, the preview opens in a new tab.
20 (f is the form object for the model.)
21
22 ## More options:
23
24 previewable :actions => [:mycreate]
25 The preview functionality works for forms that submit to the `mycreate` action, instead of the default (`create`, `update`)
26
27 previewable :template => "myshow"
28 The preview is generated using the _myshow.html.erb_ template instead of the default (_show.html.erb_)
29
30 ## How it works:
31 When the form is submitted through the preview button, it sends all the form values to the create/update actions on the server.
32 This gem adds a before_filter to those actions, where it creates the resource instance variable (@post for PostsController) using the passed values, and then renders the template using the instance variable.
33
34 ## Note:
35 The resource preview object is not persisted - no data is written to the database.
Something went wrong with that request. Please try again.