添加用户注册功能
This commit is contained in:
parent
42e6f42a7a
commit
97e1ce858e
|
@ -1,10 +1,19 @@
|
||||||
#encoding: utf-8
|
#encoding: utf-8
|
||||||
class UsersController < ApplicationController
|
class UsersController < ApplicationController
|
||||||
def register
|
def register
|
||||||
|
@user = User.new
|
||||||
|
render 'register', layout: 'register'
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def register_confirm
|
def register_confirm
|
||||||
|
@user = User.new params.require(:user).permit(:username,:em ail,:password,:password_confirmation)
|
||||||
|
if @user.save
|
||||||
|
to_login @user
|
||||||
|
redirect_to root_path
|
||||||
|
else
|
||||||
|
render 'register', layout: 'register'
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -25,4 +34,4 @@ class UsersController < ApplicationController
|
||||||
def to_login(user)
|
def to_login(user)
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue