Rails textarea和content_for

时间:2016-05-05 11:52:37

标签: ruby-on-rails

是否可以使用一个textarea和少量content_for

我的目标是分成几个部分的内容

我想像它一样使用

content_for :headercontent_for :body

content_for :footer

所以我想写全文并将其分开

yield :header

然后是一些内容

yield :body

然后是图像

yield :footer

我不想为每个content_for

创建textarea

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

是的,你可以完全按照自己的意思行事。请参阅GuideAPI Doc。我倾向于使用content_for代替yield这样(来自文档):

<% content_for :not_authorized do %>
   alert('You are not authorized to do that!')
<% end %>

然后

<%= content_for :not_authorized if current_user.nil? %>