Skip to content

Commit

Permalink
Add sign_up form example.
Browse files Browse the repository at this point in the history
  • Loading branch information
maxim authored and josevalim committed Nov 11, 2009
1 parent 91ace10 commit c522255
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Expand Up @@ -6,5 +6,5 @@ class ApplicationController < ActionController::Base
protect_from_forgery # See ActionController::RequestForgeryProtection for details

# Scrub sensitive parameters from your log
filter_parameter_logging :password
filter_parameter_logging :password, :password_confirmation
end
22 changes: 20 additions & 2 deletions app/controllers/users_controller.rb
@@ -1,6 +1,24 @@
class UsersController < ApplicationController
before_filter :authenticate_user!

before_filter :authenticate_user!, :only => [:edit, :update]

def new
@user = User.new
end

def create
@user = User.new(params[:user])

if @user.save
flash[:success] = @user.respond_to?(:confirm!) ?
t('devise.confirmations.send_instructions') :
t('flash.users.create.notice', :default => 'User was successfully created.')

redirect_to root_url
else
render :new
end
end

def edit
@user = current_user
end
Expand Down
1 change: 1 addition & 0 deletions app/views/home/index.html.erb
Expand Up @@ -4,6 +4,7 @@
<% end -%>
<% unless user_signed_in? -%>
<p><%= link_to 'Login as User', new_user_session_path %></p>
<p><%= link_to 'Sign Up as User', new_user_path %></p>
<% end -%>

<p>Hello World!</p>
13 changes: 13 additions & 0 deletions app/views/users/new.html.erb
@@ -0,0 +1,13 @@
<% title 'Sign Up' -%>
<% form_for @user, :url => user_path do |f| -%>
<%= f.error_messages %>
<p><%= f.label :email %></p>
<p><%= f.text_field :email %></p>
<p><%= f.label :password %></p>
<p><%= f.password_field :password %></p>
<p><%= f.label :password_confirmation %></p>
<p><%= f.password_field :password_confirmation %></p>

<p class="submit"><%= f.submit "Sign Up" %></p>
<% end -%>
2 changes: 1 addition & 1 deletion config/routes.rb
Expand Up @@ -2,7 +2,7 @@
map.devise_for :users, :admin

map.resources :home, :only => :index
map.resource :user, :only => [:edit, :update]
map.resource :user, :only => [:new, :create, :edit, :update]
map.resources :admins, :only => [:index]

map.root :controller => :home
Expand Down

0 comments on commit c522255

Please sign in to comment.