diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index dc35335..bfb93ba 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 91c4bb9..6ee45d8 100644 --- a/app/controllers/users_controller.rb +++ b/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 diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 6f6002d..ab9fdab 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -4,6 +4,7 @@ <% end -%> <% unless user_signed_in? -%>

<%= link_to 'Login as User', new_user_session_path %>

+

<%= link_to 'Sign Up as User', new_user_path %>

<% end -%>

Hello World!

diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb new file mode 100644 index 0000000..0b29417 --- /dev/null +++ b/app/views/users/new.html.erb @@ -0,0 +1,13 @@ +<% title 'Sign Up' -%> + +<% form_for @user, :url => user_path do |f| -%> + <%= f.error_messages %> +

<%= 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" %>

+<% end -%> diff --git a/config/routes.rb b/config/routes.rb index d5b122e..b7885fa 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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