我创建控制器:
class SigninController < ApplicationController
def index
end
def create
@user = User.find_by_email(params[:user][:email])
if @user
....
sign_in(:user, @user)
else
@user = User.new(params...)
@user.save
...
end
end
end
我正确地调用sign_in方法吗?
登录/index.html.erb:
<h2>Sign in</h2>
<%= form_for(User.new, :as => :user, :url => "signin") do |f| %>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>
<div><%= f.label :password %><br />
<%= f.password_field :password %></div>
<br>
<div><%= f.submit "Sign in" %></div>
<% end %>
如何调用 devise 的 devise sign_in 和 sign_up 方法?