Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby ActionMailer通过Rails中的嵌套属性循环_Ruby_Loops_Ruby On Rails 4_Actionmailer - Fatal编程技术网

Ruby ActionMailer通过Rails中的嵌套属性循环

Ruby ActionMailer通过Rails中的嵌套属性循环,ruby,loops,ruby-on-rails-4,actionmailer,Ruby,Loops,Ruby On Rails 4,Actionmailer,如何从控制台循环执行以下输出代码?本质上,stories是条目的嵌套属性,我需要将“story.content”传递给电子邮件模板中使用的消息变量 //output in firefox console from new.html.erb name="message[story_attributes][7][content]" //new.html.erb This is the form <% for story in @entry.stories %> <

如何从控制台循环执行以下输出代码?本质上,stories是条目的嵌套属性,我需要将“story.content”传递给电子邮件模板中使用的消息变量

//output in firefox console from new.html.erb
name="message[story_attributes][7][content]"

  //new.html.erb  This is the form
  <% for story in @entry.stories %>
    <%= fields_for "message[story_attributes][]", story do |ff| %>
      <tr>
        <th><%= ff.label(:content) %></th>
        <td><%= ff.text_area(:content) %></td>
      </tr>
    <% end %>
  <% end %>

//internal_email.html.erb - ?????
<% for ... in @message.story_attributes %>
   ?????
<% end %>
//从new.html.erb在firefox控制台中输出
name=“消息[故事属性][7][content]”
//new.html.erb这是表格
//内部_email.html.erb-?????
?????

如果应用程序未发送电子邮件,请尝试将deliver更改为deliver

另外,请确保重新初始化InternalEmail类中的值

class InternalEmail << ActionMailer::Base    
  def internal_email(message)
    @message = message
    mail(to: "", subject: "")
  end
end

class内部电子邮件谢谢Dan。电子邮件将通过省略story.content发送。只是想弄清楚如何将这些嵌套属性传递给ActionMailer。系统将查找app/views/internal\u email\u mailer/internal\u email.html.haml。尝试将某些内容放入其中。通过使用“.collect(&:content)”解决此问题。加入(“Story>>>”)。预结束(“Story>>>”)以收集所有故事并将其作为一个批次而不是单独显示。