RoR - 邮件中的动态主体(部分)(RoR - Dynamic body (part) in mailer)
我的目标是从db检索邮件程序的正文。
我创建了一个模型,用于存储db中的主体,带有简单的文本,html标签和变量(如原始静态邮件程序的主体),并在邮件程序视图中更改了主体。
我尝试使用
<%= raw @body_db.html.html_safe %>
,文本正确地从db导入,但是当我收到邮件时,没有变量的替换。示例:如果在DB模板中我有
Cliente: <%= @nome_cliente %>
,在我的邮件中我收到Cliente: <%= @nome_cliente %>
但我想要Cliente: <%= @nome_cliente %>
Cliente: Jon Doe
PS:所有变量都可以使用'静态'文本
有人能帮我吗?
谢谢
My goal is to retrieve the a mailer's body from db.
I created a model that store the body in db, with simple text, html tag and variable (as in the original static mailer's body) and changed the piece of body in mailer's view.
I tried with
<%= raw @body_db.html.html_safe %>
, the text is correctly imported from db, but when i receive the mail there isn't variables's substitution.Example: if in DB template i have
Cliente: <%= @nome_cliente %>
, in my mail i receiveCliente: <%= @nome_cliente %>
but i wantCliente: Jon Doe
P.S. : All variables are ok using 'static' text
Can someone help me?
Thanks
原文:https://stackoverflow.com/questions/39084453
满意答案
在pygame中,您需要使用您编写的代码。
#clear to reload screen.fill(0) #drawing background screen.blit(back, background ) #update pygame.display.flip()
如果您将一个播放器添加到屏幕然后移动他。 您会注意到,除非您重绘背景,否则您将不止一次看到该角色。
Pygame不只是让你在屏幕上添加图像并移动它,你必须重绘背景以摆脱前一帧。
您应该在代码中添加的另一件事是等待。
clock = pygame.time.Clock() FPS = 30 while 1: clock.tick(FPS)
这将设置帧速率。 我会说你通常会想要30到60帧,具体取决于游戏/硬件。
你当前的程序可能会重新绘制几百帧,所以这肯定会增加滞后。
当我在没有背景的我的电脑
Ubuntu 12.04
上检查这个。 即黑屏。我的帧速率在
1000 - 2000 FPS
之间。In pygame you need to use this code you wrote.
#clear to reload screen.fill(0) #drawing background screen.blit(back, background ) #update pygame.display.flip()
If you add a player to the screen and then move him. You will notice that unless you redraw the background, you will see the character more than once.
Pygame doesn't just let you add an image to the screen and move it around, you must redraw the background to get rid of a previous frame.
Another thing you should add to your code is a wait.
clock = pygame.time.Clock() FPS = 30 while 1: clock.tick(FPS)
This will set the frame rate. I'd say you would generally want this at 30 - 60 frames, depending on the game / hardware.
Your current program is probably redrawing the frame a several hundred times, so this will definately add lag.
When I checked this on my pc
Ubuntu 12.04
without a background. i.e. A Black screen.My frame rate was between
1000 - 2000 FPS
.
相关问答
更多在pygame背景中加载多个图像(Loading multiple images in pygame background)
PyGame - 获取加载图像的大小(PyGame - Getting the size of a loaded image)
试图添加一个图像作为pygame背景(trying to add an image as a pygame backgrounds)
移动背景pygame(Moving background pygame)
如何以pygame作为背景加载巨大的图像?(How can I load a huge image with pygame as a background?)
Pygame:添加背景(Pygame: Adding a background)
在pygame上使用类显示图像(Displaying an image using a class on pygame)
PyGame将cStringIO加载为图像(PyGame load cStringIO as image)
相关文章
更多ROR study
了解 Web Part 框架
getting start with storm 翻译 第二章 part-1
getting start with storm 翻译 第八章 part-2
《宁皓网:Drupal 6 基础教程 第一部》(Drupal 6 Essential Training Part 1)修正完整版[压缩包]
Java 发送邮件
Search smarter with Apache Solr, Part 1: Essential features and the Solr schema
Rails中的路由功能是如何对应的?
全球6大垃圾邮件僵尸网络
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!