问题
I'm looking to place the signup form for an app I'm building on the app's home page, however I don't know how to render the view app/views/users/new.html.erb on my home page. Is there a method I can use to accomplish this? Thanks a bunch!
回答1:
You can use a content_for block and then yield it on your application layout. Create a partial with your users/new page. (users/_new).
In your homepage.html.erb file add
<% content_for :homepage do %>
<%= render users/new %>
<% end %>
Then in your application.html.erb file add
<%= yield :homepage %>
来源:https://stackoverflow.com/questions/11334338/how-can-i-render-a-view-that-is-a-part-of-my-user-controller-on-a-static-page-li