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:
Thibault Jouan
2011-09-06 20:46:01 +00:00
parent d2f4ea59ff
commit 1057cab009
9 changed files with 143 additions and 0 deletions

View 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

View File

@@ -4,3 +4,4 @@
= f.label :password
= f.password_field :password
= f.submit 'Sign in'
= link_to 'Sign up', new_user_path

View 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'