Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我希望将我正在构建的应用程序的注册表单放在应用程序的主页上,但是我不知道如何在我的主页上呈现视图 app/views/users/new.html.erb。有没有一种方法可以用来实现这一点?非常感谢!
您可以使用 content_for 块,然后在应用程序布局中生成它。使用您的用户/新页面创建一个部分。(用户/_new)。
在你的 homepage.html.erb 文件中添加
<% content_for :homepage do %> <%= render users/new %> <% end %>
然后在你的 application.html.erb 文件中添加
<%= yield :homepage %>