从另一个action Rails调用action来保存pdf文件
我有一个用大虾生成pdf的操作,
def savepdfs
respond_to do |format|
format.pdf {} # Create PDF file and saves in /pdf/print.pdf.
logger.info "::::::::::::::::: PDF COVER PAGE CREATED :::::::::::::::::"
end
end
我不想向用户显示pdf。相反,我只想从另一个操作中调用它,
def mainaction
#I want to call something like savepdfs(:format => :pdf)
end
我该怎么做?
I have an action to generate pdfs with prawn
def savepdfs
respond_to do |format|
format.pdf {} # Create PDF file and saves in /pdf/print.pdf.
logger.info "::::::::::::::::: PDF COVER PAGE CREATED :::::::::::::::::"
end
end
I don't want to show the pdf to the user . Instead I just want to call this from another action
def mainaction
#I want to call something like savepdfs(:format => :pdf)
end
How do I do this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将其包装为私有控制器方法
Wrap it as a private controller method
这是一个 XY 问题*。您不想调用另一个操作,您想将业务逻辑放入其所属的模型中。
* http://www.perlmonks.org/index.pl?node_id=542341
This is an XY Problem*. You don't want to call another action, you want to put business logic in the model where it belongs.
* http://www.perlmonks.org/index.pl?node_id=542341