How can I render a view that is a part of my user controller on a static page like my home page?

本秂侑毒 提交于 2019-12-25 05:17:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!