我像往常一样在视图/布局中有一个 application.html.erb,其中 <%= yield %> 用于内容。现在我正在为用户帐户编写一个设置页面,其中包含一堆不同的页面(个人资料、帐户、通知等)。
控制器/settings_controller.rb
class SettingsController < ApplicationController
end
控制器/设置/account_settings_controller.rb
class Settings::AccountSettingsController < ApplicationController
end
控制器/设置/profile_settings_controller.rb
class Settings::ProfileSettingsController < ApplicationController
end
对于属于 Settings 命名空间的每个控制器,我想“始终呈现视图”,特别是包含的 views/settings/master.html.erb
<markup>
<%= yield(:settings_content) %>
</markup>
因此,例如视图 settings/profile_settings/edit.html.erb 将包含
<% content_for(:settings_content) do %>
<markup>
</markup>
<% end %>
我不知道从哪里开始。也许我的控制器应该看起来像
class Settings::AccountSettingsController < SettingsController
end
任何指导都是最受欢迎的。
编辑:
Rendered settings/account_settings/edit.html.erb within layouts/application (19.6ms)
应该成为
Rendered settings/master.html.erb within layouts/application (19.6ms)
Rendered settings/account_settings/edit.html.erb within settings/master (19.6ms)