I'm trying to call a render of sign_in
in my index page.
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
<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 .
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 "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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.