开发者

Rails - How do I run a loop inside of a mailer?

开发者 https://www.devze.com 2023-01-17 15:08 出处:网络
So it turns out mailers hate loop inside of them. So here\'s my loop. - for [\"love\", \"hate\", \"war\"].each do |f|

So it turns out mailers hate loop inside of them. So here's my loop.

- for ["love", "hate", "war"].each do |f|
  = f

Which returns this went sent through actionmailer in rails 2.3.5 :

promotion_reminder.html.haml:17: syntax error, unexpected ';开发者_如何学Python', expecting tCOLON2 or '[' or '.'
...ry_temp));}\n", 0, false);end;_hamlout.push_text("      </di...

On line #17 of app/views/notifier/promotion_reminder.html.haml

14:         
15:         - for ["love", "hate", "war"].each do |f|
16:           = f

How would you accomplish this?


Problem is with using both for and each. Try this:

- ["love", "hate", "war"].each do |f|
  = f

or this:

- for f in ["love", "hate", "war"] do
  = f

I don't use haml. Does it need end to close block?


try

- ["love", "hate", "war"].each do |f|
  = f

and watch your white sapce


- ["love", "hate", "war"].each do |f|
  = f
0

精彩评论

暂无评论...
验证码 换一张
取 消