Implement user registration feature
* Add users/new action and view * Add users/create action * Add link to sign up in sign in page
This commit is contained in:
17
app/controllers/users_controller.rb
Normal file
17
app/controllers/users_controller.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
class UsersController < ApplicationController
|
||||
skip_before_filter :authenticate!, :only => [:new, :create]
|
||||
|
||||
def new
|
||||
@user = User.new
|
||||
end
|
||||
|
||||
def create
|
||||
@user = User.new(params[:user])
|
||||
if ! @user.save
|
||||
render :new
|
||||
else
|
||||
self.current_user = @user
|
||||
redirect_to :root
|
||||
end
|
||||
end
|
||||
end
|
@@ -4,3 +4,4 @@
|
||||
= f.label :password
|
||||
= f.password_field :password
|
||||
= f.submit 'Sign in'
|
||||
= link_to 'Sign up', new_user_path
|
||||
|
8
app/views/users/new.html.haml
Normal file
8
app/views/users/new.html.haml
Normal file
@@ -0,0 +1,8 @@
|
||||
= form_for(@user, :url => users_path) do |f|
|
||||
= f.label :email
|
||||
= f.text_field :email
|
||||
= f.label :password
|
||||
= f.password_field :password
|
||||
= f.label :password_confirmation
|
||||
= f.password_field :password_confirmation
|
||||
= f.submit 'Sign up'
|
Reference in New Issue
Block a user