Sunday 15 June 2014

ruby on rails 3 - How to give option for multiple templates for one view? -


I have an application in Rail 3 where I want to give the user the default option (4 or 5 templates) to choose the template. To see your records

The approach that I'm working on is sent to the user to set the page from which he wants to use the template and will be provided based on the settings of that template. / P>

It seems easy but I'm not sure this will work for me, please suggest me some options Please note that I am talking about PDF formats.

Assume that you have a string attribute template.

Allow the user to save settings through normal controller action.

Then you can do something like this on the controller where you want to show your pdf template. / P>

  class MyController & lt; ApplicationController def shows @setting = Setting.find (params [: setting_id]) # Get answers to the installation installation. Format | Format.pdf {rendering setting.template} End ending   

This template will be named after a template named User, which is selected and stored on the settings as a string.

No comments:

Post a Comment