简体   繁体   English

在索引页面devise中调用render sign_in

[英]call render sign_in in the index page devise

I'm trying to call a render of sign_in in my index page. 我正在尝试在索引页面中调用sign_in的渲染。

I don't want to go to another page I want to stay in the same page. 我不想转到另一个我想留在同一页面上的页面。

I have tried: 我努力了:

<%= render :partial ... %>

<%= render :file %>

I get an error. 我得到一个错误。

Do you have any idea to how I can do that? 您是否知道我该怎么做?


my file in devise/sessions/_new.html.erb 我的文件在devise / sessions / _new.html.erb中

 <h2>Sign in</h2>

<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
  <div><%= f.label :email %><br />
  <%= f.email_field :email %></div>

  <div><%= f.label :password %><br />
  <%= f.password_field :password %></div>

  <% if devise_mapping.rememberable? -%>
    <div><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
  <% end -%>

  <div><%= f.submit "Sign in" %></div>
 <% end %>
<% end %>

if i put content_for on the file i get an error do you know how i can render the file in my index after clicking on the link . 如果我将content_for放在文件上,则会出现错误消息,您知道单击链接后如何在索引中呈现文件。

What error do you get? 你得到什么错误?

If you want to render a partial view inside another view, save it with a _ prefix. 如果要在另一个视图中渲染局部视图,请使用_前缀保存它。 So call your file: 因此,调用您的文件:

_sign_in.html.erb

To render a partial as part of a view use the render method within the view: 要将局部视图渲染为视图的一部分,请在视图内使用render方法:

<%= render "sign_in" %>

If it is not in the same folder as the other views of that controller, ie called 'shared' : 如果它与该控制器的其他视图不在同一文件夹中,即称为“共享”:

<%= render "shared/sign_in" %>

For more information: http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials 有关更多信息: http : //guides.rubyonrails.org/layouts_and_rendering.html#using-partials

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM