0
我使用嵌套资源在我的Rails应用程序,像这样:Rails应用继承和嵌套资源
resources :devices, :except => [:edit] do
resources :services, :only => [:index, :destroy], :controller => "devices/services"
resources :alerts, :only => [:index, :destroy], :controller => "devices/alerts"
end
现在我想做的是有设备/显示视图是“布局”为嵌套资源和 我定义任何其他子行动。
所以说,我的设备/ show.html.erb看起来是这样的:
<div class="resource">
<div class="sidebar">
<ul>
<li><%= active_link_to "General", @device, :active => :exclusive %></li>
<li><%= active_link_to "Services", device_services_path(@device) %></li>
<li><%= active_link_to "Alerts", device_alerts_path(@device) %></li>
etc..
</ul>
</div>
<div class="data">
<%= render "shared/flash_messages" %>
<%= yield %>
</div>
</div>
那么,如何去呈现子视图(设备/服务/ index.html.erb,设备/警报/index.html.erb),其中(假设的)产量是在#DATA DIV?
出了什么问题,你有什么? – jamesc
产量仅适用于布局AFAIK。我想这和产量不会呈现什么... –
所以你的问题是关于如何使用收益呢?在这种情况下,你应该看看使用content_for http://guides.rubyonrails.org/layouts_and_rendering.html#using-content_for – jamesc