我需要制作一个表格,我可以在我的炼油厂网站的每个页面上显示。我知道

rails g refinery:form

事实上,已经使用了。我只是想知道如何将生成的视图(位于/vendor/extensions中)变成我可以在整个站点上使用的部分。

先谢谢你。

有帮助吗?

解决方案

@IGNIS,它应该只是工作!

使用RefineryCMS--我有一个扩展 vendor/extensions/notices.

在那里有一个部分 app/views/custom/_displayLatestNotices.html.erb 像:

<ul id="notices">
  <% Refinery::Notices::Notice.each do |notice| %>
     <li><h3><%= notice.title %></h3>
         <p><%= notice.body %></p>
     </li>
  <% end %>
</ul>

我可以从主站点代码中显示出来,比如:

<% content_for :body do %>
  <%= render( :partial => "custom/displayLatestNotices" ) %>
<% end %>

所以,在你生成的"小部件"表单扩展中,你可能会有类似的东西: app/views/refinery/widgets/widgets/new.html.erb.

我会将其重构为两个文件,表单本身在: app/views/refinery/widgets/widgets/_new_widget_form.html.erb.在你的 new.html.erb 您可能希望部分包含此表单-并且您应该能够通过以下方式将其包含在其他地方:<%= render( :partial => "refinery/widgets/widgets/_new_widget_form" ) %> 或者甚至可能只是:<%= render( :partial => "_new_widget_form" ) %>

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top